mathiasbynens/jsesc

Given some data, jsesc returns the shortest possible stringified & ASCII-safe representation of that data.

51
/ 100
Established

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.

Stale 6m
Maintenance 0 / 25
Adoption 11 / 25
Maturity 25 / 25
Community 15 / 25

How are scores calculated?

Stars

795

Forks

53

Language

JavaScript

License

MIT

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.