URL Encoder / Decoder

Convert special characters to percent-encoding (e.g., space becomes %20) and back.

What is URL encoding?

URL encoding, also called percent encoding, replaces characters that have special meaning in a URL - or that cannot appear in one at all - with a percent sign followed by their hexadecimal byte value. A space becomes %20, an ampersand becomes %26.

It exists because URLs have a restricted character set and a grammar in which certain characters are structural. An unencoded ampersand inside a query value would be read as the start of a new parameter, silently truncating your data.

Key takeaways

  • Percent encoding replaces a character with % followed by its hex byte value.
  • A space becomes %20, or + in the older form-encoded style.
  • encodeURIComponent is for individual values; encodeURI is for whole URLs.
  • Using the wrong one of those two is the most common URL encoding bug.
  • Non-ASCII characters are encoded per UTF-8 byte, so one character can become several triplets.

Reserved characters

CharacterEncodedStructural meaning in a URL
space%20Not permitted at all
!%21Sub-delimiter
#%23Starts the fragment
$%24Sub-delimiter
&%26Separates query parameters
'%27Sub-delimiter
+%2BMeans a space in form encoding
,%2CSub-delimiter
/%2FSeparates path segments
:%3ASeparates scheme and port
=%3DSeparates parameter name and value
?%3FStarts the query string
@%40Separates userinfo from host

Unreserved characters - A-Z, a-z, 0-9, hyphen, underscore, full stop and tilde - never need encoding. The percent-encoded forms above are what each character becomes when it must be escaped. Note that this tool, like JavaScript's encodeURIComponent, leaves ! ' ( ) and * unencoded, because they are rarely a problem in practice; encode them by hand if a strict RFC 3986 consumer needs it.

encodeURI versus encodeURIComponent

This is the distinction that causes most URL encoding bugs.

encodeURIencodeURIComponent
PurposeEncode a complete URLEncode one value within a URL
Leaves : / ? # & = alone?YesNo - encodes them
Use forTidying a whole URLQuery values, path segments, form data
Encodes a spaceYes, as %20Yes, as %20
Wrong:
"/search?q=" + encodeURI("cats & dogs")
gives /search?q=cats%20&%20dogs  (the & splits the parameter)

Right:
"/search?q=" + encodeURIComponent("cats & dogs")
gives /search?q=cats%20%26%20dogs
The rule of thumb. If you are encoding a value - something a user typed, a filename, an ID - use encodeURIComponent. Only use encodeURI when you have a complete URL and want to make its existing structure safe without destroying it. When in doubt, encodeURIComponent is the safer default.

The plus sign problem

There are two conventions for encoding a space, and they are not compatible:

  • %20 - the standard percent encoding, valid anywhere in a URL.
  • + - the older application/x-www-form-urlencoded convention, used in HTML form submissions.

This means a literal plus sign in a query value must be encoded as %2B, or it will be decoded as a space. Email addresses using plus addressing - user+tag@example.com - break constantly for exactly this reason: the plus arrives at the server as a space.

If a form keeps losing the plus in email addresses, this is why. The value needs to be percent-encoded as %2B before submission, or the server needs to handle the form-encoding convention consistently.

Non-ASCII characters

Characters outside ASCII are encoded byte by byte after conversion to UTF-8, so a single character can become several percent triplets.

CharacterUTF-8 bytesEncoded
é2%C3%A9
日3%E6%97%A5
😀4%F0%9F%98%80
café5 totalcaf%C3%A9

This is why an encoded URL containing non-English text looks so much longer than the original.

Practical guidance

  • Never encode twice. Double encoding turns %20 into %2520 and is a common bug when a value passes through several layers.
  • Encode values, not separators. Build the URL structure first, then encode each value as you insert it.
  • Use your platform's URL builder where one exists - URLSearchParams in JavaScript, or the equivalent in your language - rather than concatenating strings.
  • Decode exactly once, and be wary of frameworks that decode automatically before your code sees the value.
  • Watch for encoded slashes. Some servers reject or normalize %2F in a path, which breaks values containing slashes.
Everything runs in your browser. Your data is processed entirely on your own device - nothing is uploaded, logged or stored. That matters when the payload you are debugging contains customer records, API responses or anything else you should not be pasting into a remote service.

Frequently Asked Questions

What is URL encoding?

Also called percent encoding, it replaces characters that have special meaning in a URL, or that cannot appear in one, with a percent sign followed by their hexadecimal byte value. A space becomes %20 and an ampersand becomes %26.

What is the difference between encodeURI and encodeURIComponent?

encodeURI is for a complete URL and deliberately leaves structural characters such as colon, slash, question mark and ampersand alone. encodeURIComponent is for a single value and encodes those characters too. Using encodeURI on a query value is the most common URL encoding bug.

Which one should I use?

encodeURIComponent, almost always. If you are encoding something a user typed, a filename or an ID that will sit inside a URL, that is the right function. Only use encodeURI when you already have a complete URL and want to make it safe without destroying its structure.

Why does a plus sign become a space?

Because the older form-encoding convention uses plus to mean a space. A literal plus must be encoded as %2B. This is why email addresses using plus addressing break so often - the plus arrives at the server as a space.

Which characters need encoding?

The reserved characters that have structural meaning - space, ampersand, question mark, hash, slash, colon, equals, plus, at and several others. Letters, digits, hyphen, underscore, full stop and tilde are unreserved and never need encoding.

Why does one accented character become several percent codes?

Because encoding operates on UTF-8 bytes, not characters. An accented Latin letter is two bytes, a CJK character three, and an emoji four, so each produces that many percent triplets.

What is double encoding and why is it a problem?

It happens when an already-encoded value is encoded again, turning %20 into %2520. The receiving end decodes once and gets %20 as literal text rather than a space. It usually occurs when a value passes through several layers each applying encoding.

Can I encode a list of URLs or values at once?

Yes. Tick One per line (bulk) and paste one value per line. Each line is encoded or decoded on its own, so the list keeps its line breaks instead of them becoming %0A. If one line cannot be decoded, the output says which line, and the rest still convert.

Is my data sent anywhere?

No. Encoding and decoding happen entirely in your browser and nothing is transmitted or stored.

Related Calculators