
Security News
Security Community Slams MIT-linked Report Claiming AI Powers 80% of Ransomware
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.
fast-json-stringify
Advanced tools
fast-json-stringify is x1-5 times faster than JSON.stringify().
It is particularly suited if you are sending small JSON payloads, the
advantages reduces on large payloads.
Benchmarks:
JSON.stringify array x 3,500 ops/sec ±0.91% (85 runs sampled)
fast-json-stringify array x 4,456 ops/sec ±1.68% (87 runs sampled)
JSON.stringify long string x 13,395 ops/sec ±0.88% (91 runs sampled)
fast-json-stringify long string x 95,488 ops/sec ±1.04% (90 runs sampled)
JSON.stringify short string x 5,059,316 ops/sec ±0.86% (92 runs sampled)
fast-json-stringify short string x 12,219,967 ops/sec ±1.16% (91 runs sampled)
JSON.stringify obj x 1,763,980 ops/sec ±1.30% (88 runs sampled)
fast-json-stringify obj x 5,085,148 ops/sec ±1.56% (89 runs sampled)
const fastJson = require('fast-json-stringify')
const stringify = fastJson({
  title: 'Example Schema',
  type: 'object',
  properties: {
    firstName: {
      type: 'string'
    },
    lastName: {
      type: 'string'
    },
    age: {
      description: 'Age in years',
      type: 'integer'
    },
    reg: {
      type: 'string'
    }
  }
})
console.log(stringify({
  firstName: 'Matteo',
  lastName: 'Collina',
  age: 32,
  reg: /"([^"]|\\")*"/
}))
Build a stringify() function based on
jsonschema.
Supported types:
'integer''number''array''object''boolean''null'And nested ones, too.
| Instance | Serialized as | 
|---|---|
| Date | stringviatoISOString() | 
| RegExp | string | 
You can set specific fields of an object as required in your schema, by adding the field name inside the required array in your schema.
Example:
const schema = {
  title: 'Example Schema with required field',
  type: 'object',
  properties: {
    nickname: {
      type: 'string'
    },
    mail: {
      type: 'string'
    }
  },
  required: ['mail']
}
If the object to stringify has not the required field(s), fast-json-stringify will throw an error.
If a field is present in the schema (and is not required) but it is not present in the object to stringify, fast-json-stringify will not write it in the final string.
Example:
const stringify = fastJson({
  title: 'Example Schema',
  type: 'object',
  properties: {
    nickname: {
      type: 'string'
    },
    mail: {
      type: 'string',
      required: true
    }
  }
})
const obj = {
  mail: 'mail@example.com'
}
console.log(stringify(obj)) // '{"mail":"mail@example.com"}'
This project was kindly sponsored by nearForm.
MIT
json-stringify-safe is a package that provides a safer version of JSON.stringify by handling circular references gracefully. While it focuses on safety and preventing errors during serialization, fast-json-stringify is optimized for speed and schema-based serialization.
ajv is a JSON schema validator that can also serialize JSON data. It is more focused on validation and supports a wide range of JSON schema features. While ajv can serialize data, fast-json-stringify is specifically optimized for high-performance serialization based on pre-compiled schemas.
superjson is a library that extends JSON serialization to support more JavaScript data types, such as Dates and Maps. It is designed to handle more complex data types, whereas fast-json-stringify focuses on speed and efficiency with a schema-based approach.
FAQs
Stringify your JSON at max speed
The npm package fast-json-stringify receives a total of 2,272,091 weekly downloads. As such, fast-json-stringify popularity was classified as popular.
We found that fast-json-stringify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.

Research
/Security News
Socket researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.