deftools.io Developer Tools

URL Encoder / Decoder

Encode and decode URLs, URI components, and query strings. Supports encodeURIComponent, encodeURI, and base64.

Quick Reference
encodeURIComponent
Encodes all special chars except A–Z a–z 0–9 - _ . ! ~ * ' ( ). Best for query parameter values.
encodeURI
Preserves URL-reserved chars ; , / ? : @ & = + $ #. Use for full URLs.
Base64
Binary-to-text encoding via btoa/atob. Note: UTF-8 safe via TextEncoder.

About this tool

The URL Encoder / Decoder converts text into a form that is safe to put inside a URL — and turns encoded text back into readable form. Pick one of three modes: encodeURIComponent (encodes everything except letters, digits, and - _ . ! ~ * ' ( ) — use for a single query parameter value), encodeURI (leaves URL structure characters like / ? : @ & = + $ # alone — use for a whole URL), or Base64 (a binary-to-text encoding that can carry arbitrary bytes through URL-friendly channels).

Toggle Encode and Decode, then type or paste. The Swap button feeds the output back as input and flips the direction, so you can round-trip a value and confirm it matches. The Base64 mode offers a URL-safe variant (+ → -, / → _, no padding) used by JWT tokens and similar.

Examples:

  • hello world & friendshello%20world%20%26%20friends (encodeURIComponent)
  • https://site.example/a b?q=caféhttps://site.example/a%20b?q=caf%C3%A9 (encodeURI)

FAQ

When should I use encodeURIComponent vs encodeURI?

Use encodeURIComponent for a single query parameter value, because it also encodes /, ?, =, &, and # — characters that would otherwise be misread as URL structure. Use encodeURI when you have a full URL and only want to clean up characters that are never legal in a URL (spaces, non-ASCII), while keeping its structure intact.

What is URL-safe Base64?

Standard Base64 uses + and /, which are not safe in a URL. The URL-safe variant replaces + with - and / with _, and usually drops the = padding. It is the alphabet JWT tokens use in their header and payload.

Does this tool handle Unicode?

Yes. encodeURIComponent encodes UTF-8 bytes by default, and the Base64 mode runs the input through TextEncoder/TextDecoder so emoji and non-ASCII characters round-trip correctly.

Why did decoding fail?

The most common cause is that the input is not valid for the selected algorithm — for example, a lone % that is not part of a valid percent-encoded sequence, or Base64 whose length is not a multiple of 4. Switch to the matching algorithm or toggle URL-safe mode and try again.

What is the difference between URL encoding and a URL slug?

URL encoding (percent-encoding) transforms any text — including spaces, unicode, and special characters — into a format safe for URLs, producing strings like "hello%20world". A URL slug is a clean, readable identifier like "hello-world" used for path segments. For generating readable slugs from titles, use the Slug Generator.

More developer tools

Copied!