JSURL2 Demo

Convert JSON to JSURL and back. Use the "beautify" button to format JSON.

JSON

URL-encoded ( chars)

					

JSURL

URL-encoded ( chars)

					

About JSURL2

JSURL2 aims to be a drop-in replacement for JSON encoding with better size and time characteristics.

JSURL2 has been designed to be:

Examples

Format Value
JSON {"name": "John Doé", "age": 42, "user": true, "children": ["Mary", "Bill"]}
JSON + URI encoding %7B%22name%22%3A%22John%20Do%C3%A9%22%2C%22age%22%3A42%2C%22user%22%3Atrue%2C%22children%22%3A%5B%22Mary%22%2C%22Bill%22%5D%7D
JSURL2 (name~John_Doé~age~42~user~~children~!Mary~Bill)~
JSURL2 + URI encoding (name~John_Do%C3%A9~age~42~user~~children~!Mary~Bill)~

API

var JSURL = require("jsurl2");

// Options:
// * `rich`: encode Date, `undefined`, `Infinity`
// * `short`: remove optional trailing delimiters
str = JSURL.stringify(obj[, options]);

// Options:
// * `deURI`: remove URI encoding and whitespace
obj = JSURL.parse(str[, options]);

// return `default` instead of throwing on error; options are passed to `parse()`
obj = JSURL.tryParse(str[, default][, options]);

Syntax

JSURL uses the allowable characters in URI schemes for multiple purposes depending on the location in the result. Some examples:

JSURL has a short mode, which omits unnecessary ending delimiters, saving a few more bytes.

Since browsers may choose to encode any character with URI escaping, decoding will work no matter how many encodings happened, if you pass the deURI: true option to the parser.

Source and full documentation on GitHub.