{"id":13668,"library":"node-stringify","title":"Node.js Object Stringifier for Eval","description":"node-stringify is a JavaScript utility for serializing objects into a string representation that can be directly re-evaluated using JavaScript's `eval()` function. Unlike `JSON.stringify`, it aims to preserve more JavaScript-specific constructs like `Date` objects, `RegExp`, and `function` definitions, making the output directly executable. The current stable version is 0.2.1. Given its low version number and the inherent security risks associated with `eval`, this library is not intended for general-purpose data serialization or secure environments. It explicitly warns against its use as a `JSON.stringify` replacement and does not support circular references or deeply nested objects due to its recursive implementation.","status":"abandoned","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/fuqcool/node-stringify","tags":["javascript","stringify","serialize"],"install":[{"cmd":"npm install node-stringify","lang":"bash","label":"npm"},{"cmd":"yarn add node-stringify","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-stringify","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is primarily designed for CommonJS environments.","symbol":"stringify","correct":"const stringify = require('node-stringify');"}],"quickstart":{"code":"const stringify = require('node-stringify');\n\n// Basic types\nconsole.log(`Stringifying 123: ${stringify(123)}`);\nconsole.log(`Stringifying 'abc': ${stringify('abc')}`);\nconsole.log(`Stringifying null: ${stringify(null)}`);\nconsole.log(`Stringifying undefined: ${stringify(undefined)}`);\n\n// Complex types\nconst myDate = new Date(1000);\nconsole.log(`Stringifying new Date(1000): ${stringify(myDate)}`);\n\nconst myFunction = function (a,b,c) {};\nconsole.log(`Stringifying a function: ${stringify(myFunction)}`);\n\nconst myArray = [1, 2, 3];\nconsole.log(`Stringifying an array: ${stringify(myArray)}`);\n\nconst myObject = {a: 1, b: 2};\nconsole.log(`Stringifying an object: ${stringify(myObject)}`);\n\n// Object with array, with custom options\nconst complexObject = {a: 1, b: [2, 3]};\nconsole.log(`Stringifying complex object (with parenthesis): ${stringify(complexObject)}`);\nconsole.log(`Stringifying complex object (without parenthesis): ${stringify(complexObject, {parenthesis: false})}`);\n","lang":"javascript","description":"Demonstrates stringifying various JavaScript data types, including numbers, strings, null, undefined, dates, functions, arrays, and objects, showing output with and without optional parentheses."},"warnings":[{"fix":"For general data serialization, always use `JSON.stringify()` and `JSON.parse()`. If you must re-evaluate code, ensure the source is entirely trusted and controlled.","message":"This library is explicitly NOT designed to replace `JSON.stringify`. It produces output intended for `eval()`, which has significant security implications if the input string is not absolutely trusted. Using `eval()` with untrusted input can lead to arbitrary code execution.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Ensure that objects passed to `stringify` do not contain circular references. Manual pre-processing to remove or replace circular references might be necessary, or consider alternatives that handle them (e.g., `flatted` or custom JSON replacers).","message":"The library does not support objects with circular references. Attempting to stringify an object containing a direct or indirect reference to itself will likely result in an infinite loop or a stack overflow.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"If you need the object literal without parentheses, pass `{ parenthesis: false }` as the second argument: `stringify(obj, { parenthesis: false })`.","message":"The default behavior for objects wraps the output in parentheses (e.g., `({a:1})`). This is to ensure the result is a valid expression when passed to `eval()`. However, this might be unexpected if you intend to get a plain object literal string.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Evaluate if this specific functionality is critical. If so, consider porting the necessary logic into your own codebase or finding a more actively maintained alternative if one exists for `eval`-targeted serialization. Otherwise, migrate to standard serialization methods.","message":"This package appears to be unmaintained. Its last update was in 2015, and it is at version 0.2.1. Relying on an unmaintained package for production systems introduces risks related to security vulnerabilities, compatibility issues with newer Node.js versions, and lack of bug fixes.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.2.1':60 'aim':35 'associ':71 'circular':102 'construct':42 'current':56 'data':83 'date':44 'deepli':105 'definit':49 'direct':23,53 'due':108 'environ':87 'eval':5,30,73 'evalu':26 'execut':54 'explicit':89 'function':31,48 'general':81 'general-purpos':80 'given':61 'implement':112 'inher':68 'intend':78 'javascript':11,28,40,113 'javascript-specif':39 'json.stringify':33,96 'librari':75 'like':43 'low':63 'make':50 'nest':106 'node':7 'node-stringifi':6 'node.js':1 'number':65 'object':2,15,45,107 'output':52 'preserv':37 'purpos':82 're':25 're-evalu':24 'recurs':111 'refer':103 'regexp':46 'replac':97 'represent':19 'risk':70 'secur':69,86 'serial':14,84,115 'specif':41 'stabl':57 'string':18 'stringifi':3,8,114 'support':101 'unlik':32 'use':27,93 'util':12 'version':58,64 'warn':90","created_at":"2026-04-20T01:55:41.883132+00:00","updated_at":"2026-04-20T01:55:41.883132+00:00","problems":[{"fix":"Refactor your object structure to avoid circular dependencies, or manually remove/replace offending properties before stringifying. The library is not designed to handle these cases.","cause":"Attempting to stringify an object with circular references or an excessively deep nesting level.","error":"RangeError: Maximum call stack size exceeded"},{"fix":"Use the CommonJS `require` syntax: `const stringify = require('node-stringify');`","cause":"The package is an older CommonJS module and does not natively support ES Modules `import` syntax.","error":"ReferenceError: require is not defined (when using 'import stringify from \"node-stringify\"')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/fuqcool/node-stringify","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/node-stringify","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}