Copynix

URL Encoder and Decoder Online β€” encodeURIComponent / decodeURIComponent

Frequently Asked Questions

What is URL encoding?

URL encoding (percent-encoding) replaces special characters with a '%' followed by two hex digits. For example, a space becomes %20 and '/' becomes %2F. This ensures URLs are valid and unambiguous.

What is the difference between encodeURI and encodeURIComponent?

encodeURI encodes a full URL and preserves characters like '/', '?', '#', while encodeURIComponent encodes individual query parameter values and encodes those characters too. This tool uses encodeURIComponent.

When do I need to URL-encode a string?

When you include user-provided strings as URL query parameters, always URL-encode them to prevent broken URLs or injection vulnerabilities.

Why do spaces sometimes appear as '+' instead of '%20'?

In HTML form submissions (application/x-www-form-urlencoded), spaces are encoded as '+'. In standard URL percent-encoding, spaces are '%20'. This tool uses the standard %20 encoding.

Why does my URL contain %20?

%20 is the URL-encoded representation of a space character. When you include text with spaces in a URL query parameter, the spaces must be encoded to keep the URL valid. Decode the URL here to see the original readable text.

How do I decode a URL in JavaScript?

Use decodeURIComponent() to decode individual query parameter values (reverses %20, %2F, etc.). Use decodeURI() for full URLs, which preserves reserved characters like '/', '?', '#'. Avoid eval() or manual string replacement for URL decoding.

What characters are safe in a URL without encoding?

Unreserved characters are always safe without encoding: letters (A-Z, a-z), digits (0-9), and the symbols - _ . ~ . All other characters, including spaces, &, =, +, #, and non-ASCII characters, should be percent-encoded in query parameters.

URL encoding converts special characters into a percent-encoded format that can safely travel through URLs. This is essential for building dynamic URLs with query parameters, and for preventing injection vulnerabilities in web applications.

How to use

  1. 1

    Choose encode or decode

    Select 'Encode' to convert a plain string to URL-safe format. Select 'Decode' to reverse a percent-encoded string back to readable text.

  2. 2

    Paste your input

    For encoding: paste a URL query parameter value (e.g. a search term, email address, or any string with spaces or special characters). For decoding: paste a percent-encoded string like 'hello%20world%21'.

  3. 3

    Copy the output

    The encoded or decoded result appears instantly. Copy it directly for use in your code, browser address bar, or HTTP request.

  4. 4

    Encode full URLs vs. components

    This tool uses encodeURIComponent β€” the correct function for encoding individual query parameter values. Do not use it to encode full URLs (that would incorrectly encode slashes and colons in the scheme and host).

Use cases

  • Build dynamic search URLs

    When building a link like /search?q=user+input, always URL-encode the query parameter to handle spaces, ampersands, and special characters correctly. Without encoding, characters like & break the URL structure.

  • Debug percent-encoded strings

    API logs, server logs, and email links often contain percent-encoded URLs that are hard to read. Decode them here to see the original parameter values and debug routing or query issues.

  • Construct API requests manually

    When crafting HTTP requests in tools like curl or Postman, URL-encode query parameters with spaces or non-ASCII characters to ensure the request is correctly parsed by the server.

Related Tools

HTML Entities

HTML encode & preview

Base64

Encode & decode Base64

JSON

Format & minify JSON

Regex

Test regex with highlighting

URL encoding (percent-encoding) replaces characters that are not allowed in URLs β€” spaces, accented letters, brackets, and most special characters β€” with a percent sign followed by their two-digit hexadecimal byte value. For example, a space becomes %20 and an ampersand becomes %26. This encoding is required by RFC 3986 to ensure URLs are transmitted correctly across all HTTP clients, servers, and intermediaries.

You typically need URL encoding when constructing query strings with dynamic values, passing special characters in route parameters, encoding redirect URIs in OAuth flows, or debugging a 400 Bad Request caused by illegal characters in a URL. This tool encodes individual URL components (not full URLs), handles full UTF-8 multibyte characters, and lets you toggle between encoding and decoding in either direction.