Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

URL-friendly JSON

branch: master

Merge pull request #3 from resin-io/master

add bower.json
latest commit 77ead95a00
Bruno Jouhier bjouhier authored
Octocat-spinner-32 examples added demo page September 04, 2013
Octocat-spinner-32 lib beautified September 04, 2013
Octocat-spinner-32 test beautified September 04, 2013
Octocat-spinner-32 AUTHORS first commit November 04, 2011
Octocat-spinner-32 Fixed typo in example December 26, 2012
Octocat-spinner-32 bower.json add bower.json September 17, 2013
Octocat-spinner-32 index.js beautified September 04, 2013
Octocat-spinner-32 package.json first commit November 04, 2011


JSURL is an alternative to JSON + URL encoding (or JSON + base64 encoding). It makes it handy to pass complex values via URL query parameters.

JSURL has been designed to be:

  • Compact: its output is much more compact than JSON + URL encoding (except in pathological cases). It is even often slightly more compact than regular JSON!
  • Readable: its output is much more readable than JSON + URL encoding.
  • Foolproof: its output only contains characters that are unaffected by URL encoding/decoding. There is no risk of missing a URL encoding/decoding pass, or of messing up a JSURL string by applying an extra URL encoding or decoding pass.
  • Easy to generate and parse


Think of it as JSON with the following changes:

  • Curly braces ({ and }) replaced by parentheses (( and ))
  • Square brackets ([ and ]) replaced by (~ and )
  • Property names unquoted (but escaped -- see below).
  • String values prefixed by a single quote (') and escaped
  • All other JSON punctuation (colon : and comma ,) replaced by tildes (~)
  • An extra tilde (~) at the very beginning.

Property names and string values are escaped as follows:

  • Letters, digits, underscore (_), hyphen (-) and dot (.) are preserved.
  • Dollar sign ($) is replaced by exclamation mark (!)
  • Other characters with UNICODE value <= 0xff are encoded as *XX
  • Characters with UNICODE value > 0xff are encoded as **XXXX



{"name":"John Doe","age":42,"children":["Mary","Bill"]}



JSON + URL encoding:



var JSURL = require("jsurl");

str = JSURL.stringify(obj);
obj = JSURL.parse(str);


The easiest way to install jsurl is with NPM:

npm install jsurl


This work is licensed under the MIT license.

Something went wrong with that request. Please try again.