URI percent-encoding (encodeURI & encodeURIComponent)

Client

JavaScript exposes two families: encodeURI / decodeURI for strings that already look like URIs, and encodeURIComponent / decodeURIComponent for a single component. Use the workspace below to see the difference on the same paste.

Part of encoding tools.

Workspace

Each button replaces the field with the result so you can copy it. Errors surface when percent-sequences are invalid for the chosen decoder.

encodeURI / decodeURI

?

For strings that already look like URIs: encodeURI escapes characters that are illegal in URIs but keeps separators like /, ?, and #. Pair with decodeURI.

Use this when you need a mostly intact URL string with only illegal characters escaped—not for isolated query values.

encodeURIComponent / decodeURIComponent

?

encodeURIComponent escapes almost everything, including / and ?. Use it for a single path segment, form field, or query value before concatenating into a URL.

The Base64 & URL page also exposes these two—this page adds encodeURI / decodeURI for full strings.

Common use cases

  • Escape illegal characters in a mostly complete URL while keeping slashes and query structure (encodeURI).
  • Escape a path segment, form field, or query value before concatenating it into a URL (encodeURIComponent).
  • Round-trip test strings that mix spaces, Unicode, and reserved characters.

Common mistakes to avoid

  • Using encodeURIComponent on an entire URL

    It will escape ? and /, which breaks the URL shape—use encodeURI for full strings, or encode only the pieces that need it.

  • Mixing up decodeURI with decodeURIComponent

    Pair decodeURI with encodeURI and decodeURIComponent with encodeURIComponent—otherwise you can double-decode or leave stray % sequences.

FAQ

When should I use the Base64 & URL page instead?

That page focuses on UTF-8 Base64 plus URL component encoding in one flow. This page adds encodeURI / decodeURI for full URI strings.

Does anything leave my browser?

No. All transforms run locally in your tab.

Common search terms

Phrases people search for that match this tool. See the full long-tail keyword index.

  • encodeuri vs encodeuricomponent
  • percent encode full url online
  • decodeuri decodeuricomponent online
  • javascript uri encoding difference

Related utilities you can open in another tab—mostly client-side.