Gathering detailed insights and metrics for javascript-stringify
Gathering detailed insights and metrics for javascript-stringify
Gathering detailed insights and metrics for javascript-stringify
Gathering detailed insights and metrics for javascript-stringify
fast-safe-stringify
Safely and quickly serialize JavaScript objects
safe-stable-stringify
Deterministic and safely JSON.stringify to quickly serialize JavaScript objects
jsesc
Given some data, jsesc returns the shortest possible stringified & ASCII-safe representation of that data.
pretty-format
Stringify any JavaScript value.
Stringify is to `eval` as `JSON.stringify` is to `JSON.parse`
npm install javascript-stringify
Typescript
Module System
Node Version
NPM Version
99.7
Supply Chain
100
Quality
76
Maintenance
100
Vulnerability
100
License
Use `Buffer.from`
Updated on Apr 14, 2021
Custom Function Properties
Updated on Nov 05, 2019
ESNext Function Syntaxes + TypeScript
Updated on Mar 06, 2019
Handle `Error`, `Map` and `Set`
Updated on Feb 23, 2017
Skip Undefined Properties
Updated on Nov 02, 2016
Max Values
Updated on Aug 19, 2016
TypeScript (100%)
Total Downloads
454,665,058
Last Day
109,893
Last Week
2,262,381
Last Month
9,745,002
Last Year
104,507,228
MIT License
145 Stars
81 Commits
15 Forks
4 Watchers
1 Branches
8 Contributors
Updated on Jun 07, 2025
Minified
Minified + Gzipped
Latest Version
2.1.0
Package Id
javascript-stringify@2.1.0
Size
20.31 kB
NPM Version
7.9.0
Node Version
15.14.0
Published on
Apr 14, 2021
Cumulative downloads
Total Downloads
Last Day
-11.7%
109,893
Compared to previous day
Last Week
-9.3%
2,262,381
Compared to previous week
Last Month
1.7%
9,745,002
Compared to previous month
Last Year
10.3%
104,507,228
Compared to previous year
Stringify is to
eval
asJSON.stringify
is toJSON.parse
.
npm install javascript-stringify --save
1import { stringify } from "javascript-stringify";
The API is similar JSON.stringify
:
value
The value to convert to a stringreplacer
A function that alters the behavior of the stringification processspace
A string or number that's used to insert white space into the output for readability purposesoptions
undefined
properties instead of restoring as undefined
1stringify({}); // "{}" 2stringify(true); // "true" 3stringify("foo"); // "'foo'" 4 5stringify({ x: 5, y: 6 }); // "{x:5,y:6}" 6stringify([1, 2, 3, "string"]); // "[1,2,3,'string']" 7 8stringify({ a: { b: { c: 1 } } }, null, null, { maxDepth: 2 }); // "{a:{b:{}}}" 9 10/** 11 * Invalid key names are automatically stringified. 12 */ 13stringify({ "some-key": 10 }); // "{'some-key':10}" 14 15/** 16 * Some object types and values can remain identical. 17 */ 18stringify([/.+/gi, new Number(10), new Date()]); // "[/.+/gi,new Number(10),new Date(1406623295732)]" 19 20/** 21 * Unknown or circular references are removed. 22 */ 23var obj = { x: 10 }; 24obj.circular = obj; 25 26stringify(obj); // "{x:10}" 27stringify(obj, null, null, { references: true }); // "(function(){var x={x:10};x.circular=x;return x;}())" 28 29/** 30 * Specify indentation - just like `JSON.stringify`. 31 */ 32stringify({ a: 2 }, null, " "); // "{\n a: 2\n}" 33stringify({ uno: 1, dos: 2 }, null, "\t"); // "{\n\tuno: 1,\n\tdos: 2\n}" 34 35/** 36 * Add custom replacer behaviour - like double quoted strings. 37 */ 38stringify(["test", "string"], function (value, indent, stringify) { 39 if (typeof value === "string") { 40 return '"' + value.replace(/"/g, '\\"') + '"'; 41 } 42 43 return stringify(value); 44}); 45//=> '["test","string"]'
You can use your own code formatter on the result of javascript-stringify
. Here is an example using eslint:
1const { CLIEngine } = require("eslint"); 2const { stringify } = require("javascript-stringify"); 3 4const { APP_ROOT_PATH, ESLINTRC_FILE_PATH } = require("./constants"); 5 6const ESLINT_CLI = new CLIEngine({ 7 fix: true, 8 cwd: APP_ROOT_PATH, 9 configFile: ESLINTRC_FILE_PATH, 10}); 11 12module.exports = (objectToStringify) => { 13 return ESLINT_CLI.executeOnText(stringify(objectToStringify)).results[0] 14 .output; 15};
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
project is fuzzed
Details
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
Found 6/25 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
23 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More