Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
JavaScript JSON encoder/decoder that preserves precision.
branch: master


latest commit 09577c50da
Wade Simmons authored
Failed to load latest commit information.
benchmarks add benchmarks add Benchmarks and Changelog to README
decimaljson.js remove console.log
package.json 0.2.2


Very simple JSON parser that preserves the full precision of numbers. It is a fork of json_parse.js from JSON-js. This module should work in browsers and any CommonJS system (tested with Node.js)

Numbers will be parsed into a Decimal class, with .string and .number attributes


For Node.js:

npm install decimaljson

For browser use:

<script src='decimaljson.js' />
<!-- DJSON will be available as a global now -->


// Only for Node.js
> var DJSON = require('decimaljson')

> var array = DJSON.parse('[1.0000000000000001]')
> array
[ Decimal(1.0000000000000001) ]
> array[0].string
> array[1].number


Benchmarks for DJSON.parse and DJSON.stringify are provided. Here are some example results from my laptop:

node 0.2.6 (x86, v8 2.3.8):
  - JSON.parse is 2x faster than DJSON.parse
  - JSON.stringify and DJSON.stringify are the same speed

node 0.4.1 (x86, v8 3.1.5):
  - JSON.parse is 4.5x faster than DJSON.parse
  - JSON.stringify is 3x faster than DJSON.stringify


  • 0.2.0: Added DJSON.stringify. Added benchmarks.
  • 0.1.0: Initial release, DJSON.parse.


  • Try to make a native module for Node.js that uses a modified version of the v8 JSON parser. This is harder than I expected as JSON.parse is implemented by using a special case of the V8 JS parser.
Something went wrong with that request. Please try again.