Waiting for input

For one value inside a URL, such as a query parameter. Encodes everything except letters, digits and - _ . ! ~ * ' ( ). Same as encodeURIComponent.

Input

Output

Highlighted = changed by this step

 

The result appears here as you type.

    Ctrl+Enter run / or Ctrl+K search tools Press Ctrl+D to bookmark this page

    How to encode or decode a URL

    1. Choose Encode or Decode, then a mode. The line under the options says what the mode does.
    2. Paste or type into the Input box, or drop a text file onto it. The result appears in the Output box as you type, with every changed character highlighted.
    3. Copy or download the result. Swap moves the output into the input and flips the direction, so you can check that a value decodes back to what you started with.

    When you decode a URL or a query string, the tool also splits it into its parts and lists every parameter with its decoded and raw value, in order, including repeated names. Each value has its own copy button.

    What percent-encoding is

    A URL may only contain a small set of ASCII characters, and some of them have a job: ? starts the query, & separates parameters, # starts the fragment. Any other character, or one of those used as plain text, is written as its UTF-8 bytes, each as a % followed by two hex digits. A space becomes %20, and é, which is two bytes in UTF-8, becomes %C3%A9.

    Encoding a value before you put it in a URL keeps its characters from being read as structure. Without it, a search for fish & chips sent as ?q=fish & chips would arrive as the value fish , plus a second parameter named chips with no value.

    The four modes, and when to use each

    Each mode leaves a different set of characters alone. Here is what each one does to a b&c/é!:

    ModeUse it forResult
    ComponentOne value going inside a URL, such as a query parameter or a path segment. The usual choice.a%20b%26c%2F%C3%A9!
    Full URLA whole URL that has spaces or non-ASCII text in it. Characters with a job in URLs stay as they are.a%20b&c/%C3%A9!
    FormHTML form data and query strings built the way browsers build them. Spaces become +.a+b%26c%2F%C3%A9%21
    RFC 3986APIs and signatures that need the strict standard, such as OAuth 1.0. Only letters, digits and - . _ ~ are kept.a%20b%26c%2F%C3%A9%21

    Decoding in Full URL mode works like the browser's decodeURI: escapes such as %2F, %26 and %3F are left encoded, because decoding them would change the URL's structure. A value that contains an encoded & stays one value. Component mode decodes everything.

    %20 or +: which one is a space?

    Both, depending on where the text is. In the query string of a form submission (application/x-www-form-urlencoded), + means a space and a real plus sign is written %2B. Everywhere else, including the path, a + is just a plus sign and a space must be %20.

    This difference causes many bugs. A phone number such as +44 20 7946 0000 sent unencoded in a query string arrives as  44 20 7946 0000, with a leading space. In the other direction, a form decoder turns every + in a Base64 value into a space and breaks it. If you decode text with + signs in a query string in Component mode, the tool tells you and offers to decode it as form data instead.

    Double encoding

    Encoding text that is already encoded encodes its % signs again: %20 becomes %2520. It usually happens when two layers of code each encode the same value, and the receiving side then sees a literal %20 instead of a space.

    When decoded output still contains escapes that decode cleanly, the tool says how many times the input looks encoded and can decode all the layers at once. It never does this on its own, because sometimes an encoded value inside a URL is meant to stay encoded, such as a redirect_uri parameter. Encoding text that already has escapes in it also gets a warning, with a one-click switch to Decode.

    Decoding errors and what they mean

    Every problem is listed with its line and column, and the bad sequence is marked in red.

    InputProblemFix
    %2 or a trailing %Incomplete escape: the text ends before two hex digitsRestore the missing digits. The text was often cut off.
    %ZZ, 100% sureNot an escape: a % is not followed by two hex digitsWrite a literal percent sign as %25
    M%E4rzValid escapes, but the bytes are not UTF-8Probably Windows-1252. Use Decode as Windows-1252
    %C3 on its ownHalf of a UTF-8 characterThe text was cut in the middle of a character. Restore the rest, such as %C3%A9 for é

    About Latin-1. Older forms and servers sometimes send text in Windows-1252, often called Latin-1, where ä is the single byte %E4 instead of UTF-8's %C3%A4. Browsers read the label "latin1" as Windows-1252, and so does this tool. The two differ only for bytes %80 to %9F: Windows-1252 has characters such as € and curly quotes there, while strict ISO-8859-1 has invisible control characters. The tool tells you when your text contains those bytes.

    Common characters and their encoding

    CharacterEncodedNote
    space%20Form data uses + instead
    !%21Kept by Component mode
    #%23Starts the fragment
    $%24
    %%25Must always be encoded
    &%26Separates query parameters
    '%27Kept by Component mode
    (%28Kept by Component mode
    )%29Kept by Component mode
    *%2AKept by Component and Form mode
    +%2BMeans a space in form data
    ,%2C
    /%2FSeparates path segments
    :%3AAfter the scheme and before a port
    ;%3B
    =%3DSeparates a name from its value
    ?%3FStarts the query
    @%40Separates user info from the host
    é%C3%A9Two UTF-8 bytes
    €%E2%82%ACThree UTF-8 bytes
    😀%F0%9F%98%80Four UTF-8 bytes

    Letters, digits and - . _ ~ never need encoding. Encoding letters as escapes, such as %41 for A, is allowed, but nothing needs it.

    Your input stays in your browser

    Encoding and decoding run on your device. Nothing you paste is sent to a server, and this tool does not save your input, because URLs often carry password-reset links, sign-in codes and signed download links.

    Shared links include your input only if you turn that on. The input then goes after the #, which browsers never send to a server. Anyone with the link can still read it, and it stays in browser history, so the tool warns you before adding anything that looks like a token, a signature or a password. When you open a shared link, the input is loaded and then removed from the address bar.

    Frequently asked questions

    What is the difference between encodeURI and encodeURIComponent?

    encodeURIComponent encodes everything that could break a URL, including / ? & = and #, so use it for one value that goes inside a URL. encodeURI keeps those characters, so use it for a whole URL that only has spaces or non-ASCII text to fix. Here they are Component mode and Full URL mode.

    Why do spaces sometimes become + instead of %20?

    HTML forms send data as application/x-www-form-urlencoded, where a space is written as + and a real plus sign as %2B. Everywhere else in a URL, + is a plain plus sign and a space must be %20. Use Form mode for form data and query strings built by forms.

    Why does my decoded text still contain %20 or %2F?

    Either the text was encoded twice, so one decode only removes one layer, or you decoded in Full URL mode, which keeps escapes like %2F and %26 so the URL keeps its structure. The tool tells you which, and can decode all the layers or switch to Component mode.

    What does "Not valid UTF-8" mean?

    The escapes are well formed, but the bytes do not make valid UTF-8 text. They usually come from an older encoding such as Windows-1252 (often called Latin-1), where ä is %E4. Use Decode as Windows-1252 to read them.

    Which characters never need encoding?

    Letters A to Z and a to z, digits 0 to 9, and the four characters - . _ ~ are safe everywhere in a URL. Every other character is safest encoded when it is part of a value.

    Is my URL sent to a server or saved?

    No. Encoding and decoding run in your browser, and this tool never saves your input, because URLs often contain tokens and signed links. Shared links include your input only if you turn that option on.

    URL encode and decode in your code

    Encoding a value, building form data, decoding, and reading query parameters in Java, JavaScript, Python and Go, using each standard library. Note how each language treats + and spaces differently.

    Java

    import java.io.PrintStream;
    import java.net.URLDecoder;
    import java.net.URLEncoder;
    import java.nio.charset.StandardCharsets;
    
    public class UrlEncode {
        public static void main(String[] args) {
            PrintStream out = new PrintStream(System.out, true, StandardCharsets.UTF_8);
            String text = "Café & crème 50%";
    
            // URLEncoder does form encoding: spaces become +.
            String form = URLEncoder.encode(text, StandardCharsets.UTF_8);
            out.println(form);
    
            // One value with %20 for spaces. A real + in the text is already %2B,
            // so replacing + afterwards is safe.
            out.println(form.replace("+", "%20"));
    
            // URLDecoder also reads + as a space.
            out.println(URLDecoder.decode("Caf%C3%A9+%26+cr%C3%A8me", StandardCharsets.UTF_8));
    
            // A cut-off escape throws IllegalArgumentException.
            try {
                URLDecoder.decode("%E4%", StandardCharsets.UTF_8);
            } catch (IllegalArgumentException e) {
                out.println("IllegalArgumentException");
            }
        }
    }

    Standard library only (Java 10 or later for the Charset overloads).

    JavaScript

    // Percent-encoding with the built-in functions. They always use UTF-8.
    const text = 'Café & crème 50%';
    
    // One value inside a URL (Component mode): spaces become %20.
    console.log(encodeURIComponent(text));
    
    // Form data and query strings (Form mode): spaces become +.
    console.log(new URLSearchParams({ q: text }).toString());
    
    // Decoding. A + stays a + here.
    console.log(decodeURIComponent('Caf%C3%A9%20%26%20cr%C3%A8me'));
    
    // Query parameters: + is read as a space, repeated names are kept.
    const params = new URLSearchParams('q=caf%C3%A9+%26+cr%C3%A8me&tag=a&tag=b');
    console.log(params.get('q'));
    console.log(params.getAll('tag'));
    
    // A bad escape throws a URIError (with no position).
    try {
      decodeURIComponent('%E4%');
    } catch (e) {
      console.log(e.name);
    }

    Python

    from urllib.parse import parse_qs, quote, unquote, urlencode
    
    text = "Café & crème 50%"
    
    # One value inside a URL. safe="" also encodes "/" (the default keeps it).
    print(quote(text, safe=""))
    
    # Form data and query strings: spaces become +.
    print(urlencode({"q": text}))
    
    # Decoding. A + stays a + here (use unquote_plus for form data).
    print(unquote("Caf%C3%A9%20%26%20cr%C3%A8me"))
    
    # Query parameters: + is read as a space, repeated names are kept.
    params = parse_qs("q=caf%C3%A9+%26+cr%C3%A8me&tag=a&tag=b", keep_blank_values=True)
    print(params["q"][0])
    print(params["tag"])
    
    # unquote quietly replaces bytes that are not UTF-8. Ask it to fail instead:
    try:
        unquote("%E4", errors="strict")
    except UnicodeDecodeError as e:
        print(type(e).__name__)

    Go

    package main
    
    import (
    	"fmt"
    	"net/url"
    	"strings"
    )
    
    func main() {
    	text := "Café & crème 50%"
    
    	// Form data and query strings: spaces become +.
    	fmt.Println(url.QueryEscape(text))
    
    	// One value with %20 for spaces. A real + in the text is already %2B,
    	// so replacing + afterwards is safe.
    	fmt.Println(strings.ReplaceAll(url.QueryEscape(text), "+", "%20"))
    
    	// QueryUnescape reads + as a space. (url.PathUnescape keeps it.)
    	decoded, err := url.QueryUnescape("Caf%C3%A9+%26+cr%C3%A8me")
    	fmt.Println(decoded, err)
    
    	// ParseQuery keeps repeated names.
    	params, err := url.ParseQuery("q=caf%C3%A9+%26+cr%C3%A8me&tag=a&tag=b")
    	fmt.Println(params.Get("q"), params["tag"], err)
    
    	// Bad escapes return an error. Go does not check that the bytes are UTF-8.
    	_, err = url.QueryUnescape("%E4%")
    	fmt.Println(err)
    }

    Last verified . Each example is run automatically and its output checked.

    Settings

    Deletes everything this site keeps in your browser: saved inputs, favorites, theme, accent color and tool options.