What This Tool Does
This tool percent-encodes any text so it's safe to use in URLs and query parameters, or decodes percent-encoded URLs back to readable form. It correctly handles spaces, accented characters, emoji, and reserved URL characters per RFC 3986.
Inputs Explained
- Mode: Encode (text → URL-safe) or Decode (URL → readable text).
- Encoding Type: Component (encodes everything) or Full URL (preserves :/?#&=).
- Input: Paste the URL or text to convert.
How It Works
The tool uses encodeURIComponent() for component-level encoding (encodes all reserved characters) or encodeURI() for full-URL encoding (preserves the URL structure). Decoding uses decodeURIComponent().
Formula / Logic Used
URL Encoder & Decoder
Encode special characters in URLs or decode percent-encoded URLs back to plain text.
Step-by-Step Example
Input: hello world & café
Component encoded: hello%20world%20%26%20caf%C3%A9
Full URL example: https://example.com/page?q=hello world
encodeURI output: https://example.com/page?q=hello%20world (preserves : / ? = &)
Use Cases
- Building query strings: Safely include user-typed text in URL parameters without breaking the URL.
- API debugging: Inspect what an API actually received vs what you intended to send.
- Analytics & tracking: Encode UTM source/medium/campaign values that contain spaces or symbols.
- Sharing URLs with special characters: Convert URLs containing accents, emoji, or non-ASCII into safely shareable form.
- Decoding referrer URLs: Convert encoded referrer values from server logs back to human-readable URLs.
Assumptions and Limitations
- encodeURI does NOT encode reserved characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) — use encodeURIComponent if you want them encoded.
- Always decode using the same mode you encoded with, otherwise some characters may double-encode or under-decode.
- Maximum URL length is browser-dependent (typically 2,000–8,000 characters). Very long encoded URLs may be rejected.
- Some servers expect + for spaces (form encoding) instead of %20 — check your target system.
Frequently Asked Questions
What is the difference between encodeURI and encodeURIComponent?
encodeURI preserves URL syntax characters (: / ? # & =) so the result is still a valid URL structure. encodeURIComponent encodes everything that isn't a basic alphanumeric, so it's safe for use as a single query value.
Why does space become %20 sometimes and + other times?
%20 is the standard percent encoding for a space. + is the older form-encoded representation used in application/x-www-form-urlencoded forms. Both decode to space, but they aren't always interchangeable in URL paths.
Will my URL data be sent anywhere?
No. Both encode and decode run entirely in your browser using native JavaScript. There is no backend call for the conversion.
Can I encode emoji in URLs?
Yes. UTF-8 emoji become multi-byte percent sequences. For example, 🌍 becomes %F0%9F%8C%8D. All major browsers handle this correctly when decoding.
What about double-encoded URLs?
If text was encoded twice (e.g., %2520 instead of %20), decode it twice. This commonly happens when URL parameters are passed through multiple systems that each encode the value.
Is URL encoding the same as Base64?
No. URL encoding (percent encoding) replaces unsafe characters with %XX hex codes. Base64 converts binary data into a 64-character alphabet. They serve different purposes.
Why does my decoded URL show 'malformed URI sequence' error?
The input contains invalid percent sequences. Each % must be followed by exactly two valid hex digits. Lone % characters or partial sequences cause the error.
Can I encode a full URL safely?
Use encodeURI for the URL as a whole, or encodeURIComponent for individual query values. Never apply encodeURIComponent to a full URL — it will encode the colons and slashes.
Sources and References
- RFC 3986 — URI Generic Syntax — Official URI specification including percent encoding rules.
- MDN — encodeURIComponent() — Component-level URL encoding reference.
- MDN — encodeURI() — Full URL encoding reference.
- WHATWG URL Standard — Modern URL parsing and encoding specification.