Skip to content

URL Encoder

✨ Updates as you type 0 characters

Encoded

Paste text on the left

Spaces become %20, & becomes %26 and é becomes %C3%A9
Nothing to encode yet

URL Encoder & Decoder Online

What is URL encoding?

A web address can only hold a small set of characters: letters, digits and a few marks like - _ . and ~. Everything else gets written as a % sign followed by two hex digits. A space is %20, an ampersand is %26, and é is %C3%A9 (it takes two bytes in UTF-8, so it gets two codes). That’s URL encoding, also called percent-encoding.

It matters because some characters have a job in a URL. Say you want a search link for “coffee & cake”. Written as ?q=coffee & cake, the & starts a new parameter and the server only sees “coffee ”. Encoded, it’s ?q=coffee%20%26%20cake and the whole phrase arrives in one piece. Decoding goes the other way: it turns a link full of %20 and %C3%A9 back into text you can read.

How to use it

Paste the examples into the tool above to try them. Everything runs in your browser.

Step 1 Pick Encode or Decode

Use the switch above the result, then paste your text on the left or click Sample. The result updates as you type. Swap moves the result to the left and flips the direction, which is a quick way to check a round trip.

Step 2 Tell it what you’re encoding

The Type menu decides which characters are left alone.

  • A value (component) is the default and the one you’ll want most of the time: a search term, a name, a redirect address that goes inside another URL. It encodes / ? & = # too.
  • Full URL is for a whole address that only has spaces or accents in it. It keeps the :, /, ?, & and = that hold the URL together.
  • Form data writes spaces as +, the way an HTML form sends them. Same result as JavaScript’s URLSearchParams.

Try it: a message sent as form data

Text:

Hi Sam, coffee at 3?

Form data:

Hi+Sam%2C+coffee+at+3%3F

Got a list of search terms? Tick Each line and every line is encoded on its own, so you get one encoded value per line instead of one long string full of %0A (that’s the line break).

Step 3 Decoding: pluses, double codes and broken bits

Switch to Decode and paste the link. + is a space is on by default because query strings use it that way. Turn it off if your text has real plus signs, like a phone number in a path. Tick Decode until clean when a link was encoded twice (more on that below).

Broken codes don’t stop the tool. It decodes what it can, leaves the rest exactly as it was and tells you where the problem is:

Try it: a link with a cut-off character

Input:

Save 50% today: %E0%A4%A

What the tool says:

  • The % at character 8 isn’t followed by two hex digits (a % on its own is written %25).
  • %E0%A4 at character 17 is only part of a character. One or more bytes are missing.
  • %A at character 23 is cut off: a % code needs two hex digits, like %20.

Step 4 Read what the link carries, then copy

When you paste a whole link, a What’s in this link box shows up under the result. It splits the address into host, path and the part after #, and lists every query parameter with its value decoded. It’s the quickest way to see what a tracking link or a long redirect is really sending. Then click Copy.

Building the <a> tag around your link? The HTML Link Generator writes it for you, with the right target and rel.

Common URL-encoded characters

These are the ones that trip people up, shown as the default A value type writes them. Letters, digits and - _ . ~ stay as they are, with one exception: Form data also encodes the tilde, so ~ becomes %7E there.

CharacterEncodedWhy it matters
(space) %20 Or + in form data and query strings
& %26 Separates query parameters
= %3D Joins a name to its value
? %3F Starts the query string
/ %2F Separates folders in the path
# %23 Starts the part after # (the fragment)
% %25 Starts every code, so a real % needs one too
+ %2B A + on its own can mean a space
: %3A Used after https and before a port
@ %40 Used before the host in user@host
" %22 Double quote
é %C3%A9 Two bytes in UTF-8, so two codes
ü %C3%BC Also two bytes
€ %E2%82%AC Three bytes
☕ %E2%98%95 Three bytes
😀 %F0%9F%98%80 Emoji take four bytes

encodeURIComponent or encodeURI?

JavaScript has two built-in encoders, and this tool’s A value and Full URL types match them exactly. The difference is which characters they leave alone.

encodeURIComponent: for one value

encodeURIComponent('tea & biscuits?')
// 'tea%20%26%20biscuits%3F'

encodeURI: for a whole address

encodeURI('https://example.com/café menu?drink=flat white')
// 'https://example.com/caf%C3%A9%20menu?drink=flat%20white'

The first one encodes the & and the ? because, inside a value, they’re just text. The second keeps them, since a full URL needs its ? and &. The catch: encodeURI can’t tell an & that splits parameters from one that’s part of a value. Encode each value with the component version, then put the URL together.

+ or %20 for a space?

Both mean a space in a query string, because HTML forms have always sent spaces as +. These two links search for the same thing:

https://example.com/search?q=flat+white
https://example.com/search?q=flat%20white

Outside the query string it’s different. In /downloads/c++.pdf the pluses are real pluses. So %20 is the safe choice when you write a URL by hand, and a real plus sign inside a value should be written %2B.

Double encoding: spotting %2520

If encoded text gets encoded again, the % itself becomes %25. So “flat white” turns into flat%20white the first time and flat%2520white the second. You’ll know it when you see it: %25 followed by two more hex digits, or a page that shows a literal “%20” where a space should be.

To read it, switch to Decode and tick Decode until clean. To fix it for good, find the step that encodes twice. Most of the time it looks like this: the code runs encodeURIComponent on a search term and then hands it to URLSearchParams or a request library, which encodes it a second time.

URL encoding, HTML entities and Base64

They look alike but do different jobs. URL encoding (%26) makes text safe inside a web address. HTML entities (&amp;) make text safe inside HTML. A link in a page can need both: inside an href, the & between parameters is written as &amp;.

<a href="/search?q=coffee%20%26%20cake&amp;page=2">Coffee and cake</a>

Base64 is something else again: it turns any data into letters and digits, for things like small images in CSS. It isn’t a way to make a URL safe, since it uses + and / itself.

URL encoding in JavaScript

You rarely need a tool for this in code. Here’s the short version:

const q = 'coffee & cake';
const url = 'https://example.com/search?q=' + encodeURIComponent(q);
// https://example.com/search?q=coffee%20%26%20cake

// URLSearchParams builds the whole query (spaces become +)
new URLSearchParams({ q, size: 'large' }).toString();
// 'q=coffee+%26+cake&size=large'

decodeURIComponent('S%C3%A3o%20Paulo'); // 'São Paulo'

One thing to watch: decodeURIComponent throws URIError: URI malformed on a broken code like “50% off”, so wrap it in try/catch when the text comes from users.

What this tool can’t do

Frequently Asked Questions

What is URL encoding?

A way to write characters that aren’t allowed in a web address. Each one becomes a % sign plus two hex digits for every byte it takes up, so a space is %20, & is %26 and é (two bytes in UTF-8) is %C3%A9. It’s also called percent-encoding. Letters, digits and - _ . ~ never need it.

Why does a space become %20, and sometimes +?

%20 is the standard code for a space and works anywhere in a URL. The + comes from HTML forms: when a form sends data in a query string, spaces are written as +, so ?q=flat+white and ?q=flat%20white mean the same thing. In the path part of a URL a + is just a plus sign. If you’re not sure which one you need, use %20.

What’s the difference between encodeURI and encodeURIComponent?

encodeURIComponent is for one value you’re putting into a URL, like a search term. It encodes everything that could break the URL, including / ? & = and #. encodeURI is for a whole address. It leaves those characters alone because they give the URL its shape, and only encodes spaces, accents and the like. That also means it can’t protect an & inside a value. Use encodeURIComponent on each value, then build the URL around them.

Which characters need to be encoded in a URL?

Anything that isn’t a letter, a digit or one of - _ . ~ is safe to encode. Inside a query value you must encode at least & = # + % and spaces, because they’d change what the URL means. Characters outside plain ASCII, like é, ü, € or emoji, always get encoded as their UTF-8 bytes.

Why do I see %2520 in my link?

The text was encoded twice. The first time a space became %20, and the second time the % itself became %25, giving %2520. Switch to Decode and tick “Decode until clean” to get the plain text back. Then look for the step that encodes twice: often a library already encodes query values and the code encoded them before passing them in.

Why does é become %C3%A9 and not %E9?

URLs use UTF-8 today, and in UTF-8 é takes two bytes, C3 and A9. %E9 is how very old pages wrote é in the Latin-1 character set. If you decode an old link with %E9 in it, this tool tells you the code isn’t valid UTF-8 and leaves it as it was, because it can’t know for sure which old character set was meant.

What does “URIError: URI malformed” mean?

JavaScript’s decodeURIComponent throws that error when the text has a broken code, like a lone % in “50% off” or a cut-off character such as %E0%A4. This tool never throws: it decodes everything it can, leaves the broken bits as they were and tells you where they are, for example “%E0%A4 at character 12 is only part of a character”.

Is URL encoding a kind of encryption?

No. Anyone can decode it. It only makes text safe to put in a link. Don’t put passwords or private data in a URL thinking the % codes hide them: links end up in browser history, server logs and screenshots.

Is my text sent anywhere?

No. Encoding and decoding happen in your browser, and nothing you paste is uploaded or saved. The page only remembers your options (Encode or Decode, the type and the checkboxes) in this browser.