URL Encode

Encode special characters for URLs, or encode/decode JSON for URL parameters

URL encoding replaces unsafe ASCII characters with % followed by two hexadecimal digits. Essential for query strings and URL parameters.

What is URL Encoder?

URL encoding (percent encoding) converts characters into URL-safe format as defined in RFC 3986. URLs can only contain certain ASCII characters safely — letters, numbers, and a few symbols like hyphen (-), underscore (_), period (.), and tilde (~). All other characters, including spaces, quotes, brackets, and non-ASCII text (Chinese, Arabic, emojis), must be encoded as %XX (percent followed by two hexadecimal digits) to prevent misinterpretation. Query parameters, form data, and API paths require URL encoding for reliable transmission. The JSON mode lets you encode entire JSON objects for safe inclusion in URL query parameters, with validation to catch syntax errors before encoding.

How to Use

  1. Choose Text mode for plain text encoding/decoding, or JSON mode for JSON-specific encoding with validation.
  2. Select Encode or Decode direction using the toggle buttons.
  3. Enter your text or JSON in the input field on the left.
  4. In JSON mode, the tool validates your JSON before encoding to catch syntax errors early.
  5. Copy the result using the Copy button, or use 'Copy as ?data=' for JSON mode to get a ready-to-use query parameter string.

Why Use This Tool?

Make any text URL-safe instantly — encode special characters that would break URL parsing
Encode query parameters correctly — prevent & and = from splitting parameters prematurely
Handle special characters in URLs — spaces, quotes, brackets, and international text
Prepare data for API requests — most APIs expect URL-encoded query parameters
JSON mode validates input and produces query-parameter-ready output with one click
Decode URL-encoded strings back to readable text or JSON — reverse the process when needed

Tips & Best Practices

  • Spaces encode as %20 (not + in URLs) — encodeURIComponent uses %20, which is the modern standard.
  • & encodes as %26 — critical in query strings where & separates parameters and would split your value.
  • = encodes as %3D — essential in parameter values where = would be misinterpreted as a key-value separator.
  • Encode values, not the URL structure itself — don't encode ://, path slashes, or query separators.
  • For JSON in URLs, use encodeURIComponent (not encodeURI) to encode all special characters including braces and colons.

Frequently Asked Questions

What characters need URL encoding?

Characters outside the safe set (A-Z, a-z, 0-9, -, _, ., ~) need encoding. Spaces, quotes, brackets, ampersands, equals, question marks, slashes, and non-ASCII characters (accented letters, Chinese, emojis) all require encoding to prevent URL parsing errors.

When should I NOT use URL encoding?

Do not URL-encode when: you are constructing a URL and the structure characters (://, /, ?, &, =) are intentional; you are encoding data for email (use Base64); you are encoding data for HTML (use HTML entities); or you are hashing data (use a hash function, not encoding). Also, don't encode already-encoded strings — this causes double encoding.

What's the difference between encodeURI and encodeURIComponent?

encodeURI preserves URL structure characters (:/?=&) — use for full URLs. encodeURIComponent encodes everything including structure characters — use for individual parameter values. This tool uses encodeURIComponent for safe parameter encoding, which is the correct choice for query string values.

Why is URL encoding important?

URLs have strict character rules. Unencoded special characters break URL parsing: spaces truncate URLs, ampersands split parameters prematurely, quotes break HTML attributes. Encoding ensures your data survives the URL journey intact and is correctly interpreted by the receiving server.

How do I use encoded values in URLs?

For query strings: key=encodedValue. Example: search?q=hello%20world. For path segments: /path/encoded%2Fvalue. Decode on the receiving end. APIs typically expect URL-encoded query parameters — most HTTP clients handle this automatically when you pass parameter maps.

Why would I need to URL-encode JSON?

URL-encoding JSON is useful when you need to pass structured data in a URL query parameter. Common use cases include: passing filter criteria in API URLs, embedding configuration in redirect URLs, sending state data in OAuth callbacks, and pre-filling form data via URL parameters. The JSON mode validates your JSON before encoding to catch syntax errors early.

Real-world Examples

Encoding a search query with special characters

A search query containing spaces and special characters must be encoded before being included in a URL query parameter.

Input
Hello World! Search: q=test&sort=desc
Output
Hello%20World!%20Search%3A%20q%3Dtest%26sort%3Ddesc

Encoding JSON for an API query parameter

Pass a JSON filter object as a URL query parameter. The JSON mode validates the JSON and encodes it for safe inclusion in a URL.

Input
{"name":"John Doe","email":"[email protected]","tags":["developer","frontend"]}
Output
%7B%22name%22%3A%22John%20Doe%22%2C%22email%22%3A%22john%40example.com%22%2C%22tags%22%3A%5B%22developer%22%2C%22frontend%22%5D%7D

Related Tools