Irreva logo
Explore Irreva
DeveloperJanuary 17, 2026· 5 min read· Updated June 10, 2026

How to Encode and Decode URLs Online Free

Hasanur Rahman

Written by Hasanur Rahman

Founder & Full-Stack Developer · Irreva · Rangpur, Bangladesh

URLs can only contain a limited set of characters. Spaces, non-ASCII characters, and many punctuation marks need to be encoded before they're safe to use in a URL. URL encoding — also called percent encoding — replaces those characters with a % sign followed by their hexadecimal code. This guide explains why encoding is necessary and how to encode or decode any URL instantly.

Why URLs need encoding

The URL specification (RFC 3986) defines a limited set of characters that are safe to use in a URL without encoding. Letters, digits, and a handful of symbols (-_.~) are safe. Everything else must be percent-encoded.

A space, for example, must become %20. An @ sign becomes %40. An ampersand (&) is used as a query parameter separator, so if you want a literal & in a parameter value, it must be encoded as %26.

Without encoding, URLs break or behave unexpectedly. A URL with an unencoded space might be truncated at the space. An unencoded & in a parameter value would be misread as a parameter separator by the server.

  • Space → %20
  • & → %26
  • = → %3D
  • / → %2F
  • ? → %3F
  • # → %23
  • + → %2B
  • @ → %40

encodeURIComponent vs encodeURI — what's the difference

JavaScript provides two encoding functions. encodeURI() is designed for encoding a complete URL — it leaves characters like /, ?, &, and # alone because they have structural meaning in a URL. encodeURIComponent() encodes everything except letters, digits, and -_.!~*'(), making it suitable for encoding individual query parameter values.

In practice, use encodeURIComponent() when building query strings from user input. Use encodeURI() when you have a complete URL that you want to make safe without breaking its structure.

The Irreva URL Encoder lets you choose between both modes. For most use cases — encoding a search query or form value — encodeURIComponent is the right choice.

Decoding URLs — reading percent-encoded strings

Decoding converts percent-encoded sequences back to their original characters. This is useful when reading a URL from a log file, debugging a redirect chain, or understanding what parameters a URL contains.

A URL like https://example.com/search?q=hello%20world&lang=en is more readable as https://example.com/search?q=hello world&lang=en after decoding. The tool handles both full URLs and isolated query strings.

Be careful when decoding URLs from untrusted sources and then using the decoded values in HTML or SQL — decoded user input can contain characters that need separate sanitization to prevent injection attacks.

Frequently Asked Questions

What is the difference between %20 and + for spaces in URLs?

Both represent a space, but in different contexts. %20 is the percent-encoding for a space and is valid anywhere in a URL. The + sign is only valid as a space character in the query string portion of a URL (application/x-www-form-urlencoded format). In a path segment, + is a literal plus sign, not a space.

Do I need to encode an entire URL or just parts of it?

Just the parts that may contain unsafe characters — typically query parameter values and path segments that come from user input. The structural parts of the URL (scheme, host, path separators, query delimiters) should not be encoded.

Why does my URL have %2F in it?

%2F is the percent-encoding for a forward slash (/). It appears when a slash is inside a parameter value that was encoded with encodeURIComponent. If you see it unexpectedly, you may have encoded the entire URL instead of just the parameter value.

Can I encode a URL with international characters?

Yes. Non-ASCII characters like accented letters and Chinese characters are first encoded as UTF-8 bytes, then each byte is percent-encoded. For example, the é character (U+00E9) becomes %C3%A9 in a URL.

Is URL encoding the same as Base64 encoding?

No. URL encoding (percent encoding) replaces unsafe characters with %XX sequences and is used specifically for URLs. Base64 encodes arbitrary binary data into a text string using 64 printable ASCII characters. Both are encoding schemes but serve different purposes.

Hasanur Rahman

About the author

Hasanur Rahman

Founder & Full-Stack Developer · Irreva · Rangpur, Bangladesh

Hasanur Rahman is the founder of Irreva and a full-stack developer based in Rangpur, Bangladesh. He builds all of Irreva's tools with a focus on privacy-first, browser-based processing.