URL Encoder/Decoder

By Asira Tools Team · Last updated 20 November 2026

Encode text so it is safe to put in a URL, or decode a percent-encoded URL back into readable text — instantly, in your browser.

Advertisement

URL Encoder/Decoder

hello%20world%20%26%20friends%3F%20100%25%20free
Input length32 characters
Output length48 characters

Encoding uses encodeURIComponent: letters, digits, and - _ . ! ~ * ' ( ) are left alone; everything else becomes %XX. Decoding never crashes on bad input — it shows an error instead.

How percent-encoding works:

Each unsafe character is converted to its UTF-8 bytes, and each byte is written as % followed by two hexadecimal digits. A space becomes %20, & becomes %26, and % itself becomes %25.

What Is URL Encoding?

URL encoding, also called percent-encoding, is the way unsafe characters are represented inside a URL. A URL is only allowed to contain a limited set of characters: letters, digits, and a few punctuation marks. Anything else, such as a space, an ampersand, a question mark, or a non-English letter, has to be converted before it can appear in a web address. The conversion replaces each unsafe character with a percent sign followed by two hexadecimal digits that describe the character's UTF-8 bytes. A space becomes %20, an ampersand becomes %26, and a percent sign itself becomes %25.

You see percent-encoding every day without noticing it. When you search for "coffee shops near me" and the address bar shows a URL containing coffee%20shops%20near%20me, that is percent-encoding at work. When you share a link with someone and the link contains a product name with spaces and symbols, the browser encodes those characters so the link survives being pasted into an email or a chat message without breaking. Without encoding, a space in a URL would end the link early, and an ampersand would be mistaken for the separator between query parameters.

How to Use This Tool

Choose Encode to turn plain text into URL-safe text, or Decode to turn a percent-encoded string back into readable text. Type or paste your text into the input box and the result appears immediately, with the input and output lengths shown underneath. Use the Copy result button to copy the output to your clipboard. Everything happens in your browser, so you can safely encode and decode API keys, tokens, and other sensitive strings without sending them to a server.

The default example shows a typical case: the text "hello world & friends? 100% free" encodes to "hello%20world%20%26%20friends%3F%20100%25%20free". Notice that the ampersand and question mark are encoded even though they are valid URL characters in other positions. That is because this tool encodes for use inside a single value, such as one query parameter, where those characters would otherwise be read as structure rather than content.

Which Characters Get Encoded?

This tool uses the JavaScript function encodeURIComponent, which is the standard way to encode a single piece of a URL, such as one query parameter value. It leaves unreserved characters alone: the letters A to Z and a to z, the digits 0 to 9, and the marks - _ . ! ~ * ' ( ). Every other character is converted to percent-encoded form. That includes the space (%20), the double quote (%22), the hash (%23), the dollar sign (%24), the percent sign (%25), the ampersand (%26), the plus sign (%2B), the comma (%2C), the forward slash (%2F), the colon (%3A), the semicolon (%3B), the equals sign (%3D), the question mark (%3F), the at sign (%40), and the square brackets (%5B and %5D).

Non-English characters are encoded as their UTF-8 bytes, so one character can become several percent-encoded groups. The letter e with an acute accent, as in cafe, is two bytes in UTF-8, so it becomes %C3%A9. A Chinese character is three bytes and becomes three groups, and an emoji is four bytes and becomes four groups. This is why an encoded URL containing non-English text can look much longer than the original: each visible character may expand to nine characters in the encoded form.

Encoding Versus Decoding

Encoding and decoding are exact inverses of each other. Encoding turns "hello world" into "hello%20world", and decoding turns "hello%20world" back into "hello world". A round trip, encoding and then decoding, always returns the original text, provided the text was encoded correctly in the first place. This is useful for checking your work: if you decode a URL and the result looks wrong, with replacement characters or unexpected symbols, the URL was probably encoded with a different character set, such as Latin-1 instead of UTF-8, or it was encoded twice.

Double encoding is one of the most common URL bugs. It happens when a string is encoded twice: the space first becomes %20, and then the percent sign in %20 is itself encoded, giving %2520. Decoding once gives %20 instead of a space, and the text still looks encoded. If you ever see %25 in a decoded result, double encoding is the likely cause, and decoding a second time will fix it. The reverse mistake, decoding a string that was never encoded, is usually harmless unless the string contains a literal percent sign followed by two hex digits by coincidence.

Common Mistakes and Edge Cases

The most frequent mistake is encoding a whole URL instead of just one value. If you run an entire address such as https://example.com/search?q=coffee through this tool, the colons and slashes get encoded too, and the result is no longer a usable URL. Encode only the value that goes into the URL, then assemble the full address from its parts. In code, the function encodeURI exists for whole URLs, but encodeURIComponent is the right choice for individual values, and it is what this tool uses.

Another common confusion is the plus sign. In the query string of a URL, a plus sign is traditionally read as a space by form handling, because HTML forms encode spaces as + when they submit data. But in the path part of a URL, a plus sign is just a plus sign. This tool encodes a space as %20, which is unambiguous everywhere, and encodes a literal plus sign as %2B, so a plus in your text survives the round trip instead of turning into a space.

Decoding can fail, and this tool handles that gracefully instead of crashing. A percent sign must be followed by exactly two hexadecimal digits, so a string like %E0%A4%A, which ends with an incomplete UTF-8 sequence, is invalid. When decoding meets such a sequence, the tool shows an error message instead of a result. The usual fix is to check the source of the URL: a truncated copy-paste is the most common cause, followed by a percent sign that was meant literally and should have been written as %25.

Worked Example

Suppose you are building a search link for a shop, and the user searched for "red shoes & socks". The query value contains spaces and an ampersand, so it cannot go into a URL as it is: the ampersand would be read as the start of a new parameter, and the search would silently become just "red shoes ". Encoding the value gives "red%20shoes%20%26%20socks", which is 25 characters long, compared with 17 in the original. The full link becomes https://example.com/search?q=red%20shoes%20%26%20socks. When the shop's server receives that link, it decodes the parameter back to "red shoes & socks" and returns the right results. The same process applies to any value you put in a URL: names, addresses, search terms, and file names all need encoding before they travel.

Tips for Working With URLs

Encode at the last moment. Keep your data in its plain, readable form in your code and your database, and encode it only when you build the URL. Storing encoded values leads to double encoding when the value is encoded again on its way out.

Decode as soon as you receive data. When your server or your code reads a value from a URL, decode it immediately so the rest of your program works with the real text. Most web frameworks do this automatically for query parameters, so check whether yours already handles it before decoding by hand.

Never build URLs by gluing strings together by hand. Use your platform's URL builder, such as URLSearchParams in JavaScript or urllib.parse.urlencode in Python, which encodes each value correctly and assembles the query string for you. Hand-built URLs are where encoding bugs hide.

Test with awkward input. Before shipping a feature that builds URLs, try it with spaces, ampersands, question marks, percent signs, and non-English characters. If the round trip survives those, it will survive real users.

Advertisement

Frequently Asked Questions

What does %20 mean in a URL?

%20 is the percent-encoded form of a space. Each unsafe character in a URL is replaced by a percent sign followed by two hexadecimal digits for its UTF-8 byte value, and the space character is byte 0x20, so it becomes %20.

Why is my text encoded as %2520 instead of %20?

That is double encoding: the text was encoded twice. The space first became %20, and then the percent sign in %20 was encoded to %25, giving %2520. Decode twice to recover the original, and fix the code so it encodes only once.

What is the difference between encodeURI and encodeURIComponent?

encodeURI encodes a whole URL but leaves the structural characters (: / ? # &) alone, while encodeURIComponent encodes a single value and encodes those characters too. Use encodeURIComponent for query parameter values, which is what this tool does.

Why does decoding sometimes show an error?

Decoding fails when the input contains a malformed percent sequence, such as a % not followed by two hex digits, or an incomplete UTF-8 sequence like %E0%A4%A. The usual cause is a truncated copy-paste or a literal percent sign that was never encoded as %25.

How are non-English characters encoded in URLs?

They are converted to their UTF-8 bytes, and each byte becomes a %XX group. The letter e with an acute accent is two UTF-8 bytes, so cafe encodes as caf%C3%A9. An emoji is four bytes and becomes four %XX groups.