JSON Serialize

Pack a JSON document into the exact shape a column, a header, a cookie or a URL expects.

JSON
Serialized payload
Runs locally in your browser

About the JSON Serialize

Storing structured data somewhere that only accepts flat text means choosing a serialisation. A varchar column and a log field want a compact single line. An HTTP header wants Base64 so that no control character sneaks through. A shareable link wants percent encoding, and an inline fixture in a test file wants a quoted literal with the inner quotes already escaped. This tool writes all of them from the same parsed document.

The input is validated first, so a stray comma is reported before anything is packed rather than after the payload lands in production. Base64url is offered next to standard Base64 because tokens and path segments cannot carry the plus and slash characters. The data URL variant prefixes the Base64 with the application/json media type, which is handy for fixtures loaded by a fetch call in a demo.

Sorting keys before packing produces a stable byte sequence, which matters when the payload is hashed, cached or compared between two runs. Escaping non-ASCII characters converts accents and emoji into \u sequences so the result survives systems that mangle anything outside plain ASCII.

The status line shows the character count, which is the number to watch against a 2000 character URL budget or a header size limit. Reverse any of these formats with JSON Deserialize.

How to use

  1. Paste the JSON you want to pack, or press Sample to load a shopping session.
  2. Choose a target under Serialize as, from a quoted literal through to a data URL.
  3. Set a parameter name if you picked the query parameter format.
  4. Tick Sort keys first when the payload will be hashed or compared byte for byte.
  5. Copy the packed value, or download it as a text file.

Common questions

Which format should I use for a URL?
Percent encoding for a value you paste after an equals sign, or the query parameter format when you want the name and value together. Base64url is better when the payload must sit in a path segment.
Does Base64 make the payload smaller?
No, it grows by roughly a third. Base64 exists to make bytes safe for text channels, not to compress them.
Is the quoted literal ready to paste into code?
Yes. Every inner quote and backslash is escaped, so the line drops straight into a string in most languages.
Why does the output differ after ticking sort keys?
Sorting rewrites the key order alphabetically at every level. The data is identical, but the byte sequence changes, which is the point when you need a stable hash.