πŸ”₯ FireTools

How to Encode and Decode URLs: A Complete Guide

By FireTools Team Β· Updated 2026-08-28

Quick Answer

URL encoding converts unsafe characters into %XX sequences where XX is the byte's hexadecimal value. Spaces become %20 (or + in form data), Chinese characters become multi-byte %XX sequences. Use our free URL Encoder and URL Decoder β€” all processing happens locally in your browser.

Introduction

URL encoding, also known as percent-encoding, is a mechanism for encoding reserved and unsafe characters in a URL so that the URL can be safely transmitted over the internet. URLs can only contain a limited set of ASCII characters; any other character (spaces, non-ASCII letters, symbols) must be percent-encoded as a sequence starting with % followed by two hexadecimal digits representing the byte value.

Step by Step

  1. Identify what needs encoding

    Characters that are not in the unreserved set (A-Z, a-z, 0-9, -, ., _, ~) must be percent-encoded. This includes spaces, query separators like = and &, slashes, and all non-ASCII characters such as Chinese, Arabic, or emoji.

  2. Encode the URL or query string

    Paste your text into the URL Encoder tool. It uses encodeURIComponent() to encode every reserved character. The result appears instantly in the output field.

  3. Copy the encoded result

    Click the Copy button to copy the percent-encoded string. You can now safely embed it in a URL query parameter, API request, or form submission.

  4. Decode an encoded URL

    Paste an encoded URL or query string into the URL Decoder tool. It uses decodeURIComponent() to restore the original characters. Verify the decoded output matches your expectation.

  5. Verify edge cases

    Check that spaces are decoded correctly (%20 vs +), that multi-byte UTF-8 sequences decode to the right character, and that already-encoded strings are not double-encoded.

Examples

Encode text with a space

Input: Hello World

Output: Hello%20World

Encode a path separator

Input: a/b

Output: a%2Fb

Encode Chinese characters (UTF-8)

Input: δ½ ε₯½

Output: %E4%BD%A0%E5%A5%BD

Decode an encoded query parameter

Input: key%3Dvalue%26foo%3Dbar

Output: key=value&foo=bar

Common Problems

  • Double-encoding: encoding an already-encoded string turns %20 into %2520. Always check whether input is already encoded before re-encoding.
  • Confusing encodeURI with encodeURIComponent: encodeURI keeps reserved characters like /, ?, & intact for full URLs, while encodeURIComponent encodes everything for query parameter values.
  • Space handling: %20 is the percent-encoded form; + is only valid in application/x-www-form-urlencoded body data, not in URL path or query string per RFC 3986.
  • Non-UTF-8 legacy encodings: modern browsers encode as UTF-8, but legacy systems may use GBK or Latin-1, causing mojibake when decoded on the other side.

Tips

  • Use encodeURIComponent() for individual query parameter values, and encodeURI() for entire URLs that are already well-formed.
  • When building query strings, encode the value but not the = or & separators β€” encode each value separately then join with &.
  • Use our URL Encoder and Decoder tools to debug API calls that return 400 errors due to malformed query strings.
  • Always decode on the server side using the same character encoding (UTF-8) to avoid mojibake.

Related Tools

Related Guides

References