← Back to BlogDeveloper Tools

How to Encode and Decode URLs for Web Development and APIs

September 5, 2026

Written by Mohammad Sohail

URL encoding (percent-encoding) converts special characters into a format that can be safely transmitted over the internet. Spaces become %20, Chinese characters become %E4%BD%A0%E5%A5%BD, and symbols like @ become %40. Every web developer needs this daily.

When URL Encoding Is Required: Sending query parameters with special characters (search terms with spaces, symbols, non-ASCII text). Encoding form data before POST requests. Building API URLs with user-provided values. Encoding redirect URLs. Working with internationalized domain names.

Common Encodings: Space → %20 or + (in query strings). @ → %40. / → %2F. & → %26 (this is a query delimiter, so it must be encoded in values). = → %3D. # → %23 (this is a fragment delimiter). Chinese '你好' → %E4%BD%A0%E5%A5%BD. Emoji '😊' → %F0%9F%98%8A.

What I Tested: I used the [URL Encoder/Decoder](/developer-tools/url-encoder) with several inputs.

• 'hello world' → 'hello%20world'. Correct.

• 'https://example.com/path?q=test&page=1' → All special characters encoded correctly. The encoded version preserves the URL structure while encoding the values.

• 'user@example.com' → 'user%40example.com'. Correct.

• '%E4%BD%A0%E5%A5%BD' (decoded) → '你好'. Correct round-trip.

Step-by-Step: (1) Open the [URL Encoder/Decoder](/developer-tools/url-encoder). (2) Paste your text in the input field. (3) Click 'Encode' to convert special characters to percent-encoded format, or 'Decode' to reverse the encoding. (4) Copy the result.

One Limitation: The encoder does not validate whether the input is a valid URL. It simply encodes all special characters. If you paste an entire URL, it will encode the protocol, domain, and path separators, making the URL unusable. Encode individual parameter values, not entire URLs.

Common Mistake: Double-encoding. If your string is already encoded (contains %xx sequences) and you encode again, % becomes %25, turning %20 into %2520. Always check if your input is already encoded before encoding again.

Privacy: All encoding and decoding happens in your browser. No data is sent to any server.

Next Step: If you need to encode binary data (images, files) into text format, use the [Base64 Encoder](/developer-tools/base64-encoder) instead.