mathiasbynens/jsesc
Given some data, jsesc returns the shortest possible stringified & ASCII-safe representation of that data.
Supports ES6 data structures (Maps, Sets) and generates valid JavaScript output rather than JSON, with configurable escape sequences for different contexts (HTML script tags, template literals, ES6 Unicode code points). The library intelligently selects shortest escape representations (hexadecimal, Unicode, surrogate pairs) based on input and options, and handles problematic characters like U+2028/U+2029 that break JSON parsers, making it suitable for safe serialization across Node.js, browsers, and build pipelines.
795 stars. Used by 1 other package. No commits in the last 6 months. Available on npm.
Stars
795
Forks
53
Language
JavaScript
License
MIT
Category
Last pushed
Dec 11, 2024
Commits (30d)
0
Reverse dependents
1
Get this data via API
curl "https://pt-edge.onrender.com/api/v1/quality/ai-coding/mathiasbynens/jsesc"
Open to everyone — 100 requests/day, no key needed. Get a free key for 1,000/day.
Related tools
chrishoermann/zod-prisma-types
Generator creates zod types for your prisma models with advanced validation
unjs/knitwork
🧶 Utilities to generate safe JavaScript code.
microsoft/ts-gyb
Generating native code interfaces from TypeScript
retejs/rete-studio
A general-purpose code generation tool powered by Rete.js
mathiasbynens/regenerate
Generate JavaScript-compatible regular expressions based on a given set of Unicode symbols or...