# yahoo/serialize-javascript

Serialize JavaScript to a superset of JSON that includes regular expressions and functions.

Repository: https://github.com/yahoo/serialize-javascript
Canonical: https://ross.abutalabs.com/products/serialize-javascript
Language: JavaScript
License: NOASSERTION
License Family: other
Topics: javascript, web, json, serialize
Last push: 2026-08-26T13:09:24+00:00

## Health v2 (maintenance only)
Score: 98/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 99, release rhythm 96, longevity 100
- inputs: {"age_days": 4369, "days_push": 7, "days_rel": 25, "gap_med": 30.0, "n_releases_24m": 9}
- flags: no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2922, forks 213 (observed 2026-08-28T04:07:30.244858+00:00)

## What it is
A small npm library from Yahoo that serializes JavaScript values into a string of literal JavaScript code, extending JSON.stringify to support functions, regular expressions, dates, Sets, Maps, BigInt, Infinity, and URLs. The output can be embedded in HTML script tags or saved as a .js file, with HTML characters and line terminators escaped automatically.

## Use cases
- serialize javascript objects with functions and regexps to -like strings
- share route definitions with regexps from server to client
- embed serialized state into an html script tag safely
- serialize dates, maps, sets, and bigint values that .stringify cannot handle
- pass serializable state to server-side rendering hydration

## When to choose
- you need to serialize javascript values beyond what .stringify supports, like functions, regexps, dates, sets, or maps
- you want output safe to embed directly into html script elements
- you need a small, focused, well-tested serialization utility for node or the browser

## When to avoid
- you need to serialize arbitrary closures or functions that reference outside variables, such as for worker threads
- you need cross-language data interchange rather than literal javascript code
- you need secure deserialization of untrusted input

## Facets
- artifact type: library
- maturity: stable
- function: serialization
- domain: web-development, developer-tools
- platform: -
- tags: serialize-javascript, -superset, functions, regex, express-state, nodejs, javascript, web-server

## Member repositories
- yahoo/serialize-javascript (main) score 98

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:07:30.244858+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T07:33:46.580695+00:00, confidence not recorded.
  - readme: https://github.com/yahoo/serialize-javascript (fetched 2026-08-28T04:07:30.244858+00:00, sha 5c2bfaecf4f9)
  - registry_npm: https://registry.npmjs.org/serialize-javascript (fetched 2026-08-29T09:49:21.619742+00:00, sha 4545391bb97d)
- Data as of 2026-08-30T08:39:29.467469+00:00.
