Description
JSONCrush is a small JavaScript library that compresses JSON strings so they can be carried in a URL and decompressed later. You pass a JSON string to JSONCrush.crush() to compress it, and JSONCrush.uncrush() restores it. The compression uses the JSCrush algorithm, which removes repeated substrings in a way similar to zip, and it swaps common JSON characters for ones that do not need escaping in a URL. The library is aimed at URL-encoded JSON of up to about 10K characters, so that long links with data can be shared and bookmarked easily. The README's example is a 103-byte JSON string that takes 199 bytes once URI-encoded. It has no dependencies, and the minified code is under 2 KB. You can install it with npm or download the file from GitHub, and the README links a live demo. Two cautions in the README: call encodeURIComponent() when the result goes into a URL, and expect slow runs on strings longer than 10K characters. The character \u0001 is used as a delimiter and is removed if it appears in the input.…
Highlights
- Compress JSON into URL-friendly strings
- Crush and uncrush functions
- No dependencies and under 2 KB minified
- Install with npm or import the file
Ratings & Reviews
No ratings yet
Be the first to rate JSONCrush.
People also visit
Svelte Jsoneditor
A web-based tool to view, edit, format, repair, query, transform
JSONCrush FAQ
What is JSONCrush?
A small JavaScript library that compresses JSON strings so they fit in a URL and can be decompressed later.
How do I use it?
Install with npm install jsoncrush, import it, call JSONCrush.crush() on a JSON string, and call JSONCrush.uncrush() to decode.
Do I need to encode the result for a URL?
Yes. The README says to call encodeURIComponent() when the crushed string is placed in a URL.
Are there limits?
It is meant for JSON up to about 10K characters. The README says it can be slow beyond that, and that the \u0001 character is removed if it appears in the input.
What are the best JSONCrush alternatives?
Popular alternatives to JSONCrush include JaySnake, JSONT and Super JSON Formatter. See all JSONCrush alternatives
.png?auto=compress&fit=max&w=128)


