Home → JSON URL Encode Decode

JSON URL Encode Decode

URL encoding converts JSON into a format safe for use in URLs.

About This Tool

URL encoding converts JSON into a format safe for use in URLs. This tool runs entirely in your browser — no data is ever sent to a server. Free to use, no account required.

What JSON URL Encoding Is

URL encoding (percent-encoding) makes JSON safe to include in a URL by replacing special characters with their percent-encoded equivalents.

Why JSON Needs URL Encoding

JSON uses characters that have reserved meaning in URLs: { and } delimit objects, [ and ] delimit arrays, : separates keys and values, " wraps strings. Without encoding, these characters break URL parsing.

What Gets Encoded

The most commonly encoded characters are: { → %7B, } → %7D, [ → %5B, ] → %5D, " → %22, : → %3A, , → %2C, and space → %20. The encoded string is longer but unambiguous in any URL context.

Common Use Cases for JSON URL Encoding

URL-encoded JSON appears in several web development scenarios, particularly with GET request parameters and debugging.

Passing JSON in Query Strings

Some APIs accept complex filter or options objects as query string parameters. For example: GET /items?filter=%7B%22status%22%3A%22active%22%7D. This is valid for small JSON objects in GET requests.

Debugging API Requests

Browser devtools, server logs, and proxy tools often show encoded URLs. Decoding the parameters reveals the original JSON structure, which is essential for debugging API integrations.

Frequently Asked Questions

Why does JSON need to be URL encoded?+
JSON contains characters that have special meaning in URLs: curly braces {}, square brackets [], colons :, quotes ", and spaces are all reserved or unsafe. URL encoding replaces these with percent-encoded sequences (e.g., { becomes %7B) so JSON can be safely included in a query string without breaking the URL.
What is the difference between URL encoding and Base64 encoding for JSON?+
URL encoding replaces unsafe characters one-by-one and produces a string that is still partially readable. Base64 encoding converts the entire JSON string to a compact 64-character alphabet, making it unreadable but shorter for large payloads. URL encoding is standard for query parameters; Base64 is common for JWTs.
Should I URL encode JSON or put it in the request body?+
For POST, PUT, and PATCH requests, send JSON in the request body with Content-Type: application/json — do not URL encode it. URL encoding JSON is only necessary when you must pass structured data as a GET query parameter, which is generally considered bad practice for large payloads.
Can I decode a URL-encoded JSON string back to JSON?+
Yes. This tool decodes percent-encoded strings back to readable JSON. Paste the URL-encoded string into the decode input and click Decode. This is useful for debugging API requests captured in browser devtools or server logs.

URL Encoding JSON: Reference Guide

URL-encoding JSON is necessary when passing JSON data in query parameters, cookies, or URL fragments. It replaces special characters with percent-encoded equivalents.

URL Encoding Example

// Original JSON
{"name": "Alice Johnson", "city": "New York", "active": true}

// URL Encoded
%7B%22name%22%3A%22Alice%20Johnson%22%2C%22city%22%3A%22New%20York%22%2C%22active%22%3Atrue%7D

// As query parameter
https://api.example.com/search?filter=%7B%22name%22%3A%22Alice%22%7D

// JavaScript
const json = {"name": "Alice", "city": "New York"};
const encoded = encodeURIComponent(JSON.stringify(json));
const decoded = JSON.parse(decodeURIComponent(encoded));

Characters Requiring Encoding

CharacterEncoded
{%7B
}%7D
"%22
:%3A
,%2C
%20 or +
[%5B
]%5D
/%2F
+%2B
=%3D
&%26

Encoding Methods Comparison

MethodBehaviorUse Case
encodeURIComponent()Encodes everything except A-Z a-z 0-9 - _ . ! ~ * ' ( )Use for JSON in query params
encodeURI()Preserves : / ? # [ ] @ ! $ & ' ( ) * + , ; =Use for full URLs only
Base64 encodingEncodes to A-Z a-z 0-9 + / = charactersAlternative for JSON in URLs
URL-safe Base64Replaces + with - and / with _Best for JSON in JWTs and URLs

Explore more tools: All JSON Tools | Validator | Pretty Print | JSON Diff

JSON URL Encoding: How It Works

Percent-encoding converts special characters in JSON into safe sequences. Every character that is not a letter, digit, or one of -_.!~*'() is replaced with %XX where XX is the hexadecimal ASCII code for that character.

// These characters must be encoded in URLs:
// { } [ ] : " , space and more

const jsonObj = {"name": "Alice Smith", "role": "admin"};
const jsonStr = JSON.stringify(jsonObj);
// '{"name":"Alice Smith","role":"admin"}'

const encoded = encodeURIComponent(jsonStr);
// '%7B%22name%22%3A%22Alice%20Smith%22%2C%22role%22%3A%22admin%22%7D'

// Use in a URL
const url = `https://api.example.com/search?filter=${encoded}`;

// Decode on the server
const decoded = decodeURIComponent(encodedParam);
const data = JSON.parse(decoded);

URL Encode vs Base64 Encode for JSON

Aspect URL Encode Base64 Encode
Output size~30% larger~33% larger
Human readablePartially (keys recognizable)No
URL safeYesPartially (use URL-safe variant)
Use caseURL query paramsHTTP headers, data URIs, cookies
Decode complexitydecodeURIComponentatob / Buffer.from
ReversibleYesYes
Handles binaryNoYes

Passing JSON in Different HTTP Locations

Location Method Example
Query stringURL encode the JSON?data=%7B%22id%22%3A1%7D
Request bodySet Content-Type: application/jsonRaw JSON body
HTTP headerBase64 encodeX-Data: eyJpZCI6MX0=
CookieURL encode or Base64data=%7B%22id%22%3A1%7D