# json-from-script
**Repository Path**: mirrors_robinvdvleuten/json-from-script
## Basic Information
- **Project Name**: json-from-script
- **Description**: š®š» Tiny JSON parser for your CSP aware script tags.
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-08-18
- **Last Updated**: 2026-10-17
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# json-from-script
A tiny (230B) JSON parser for your CSP aware script tags.
[](https://www.npmjs.com/package/json-from-script)
[](https://github.com/robinvdvleuten/json-from-script/actions/workflows/build.yml)
[](https://licenses.dev/npm/json-from-script)
Modern front-ends often need a tiny bit of server-rendered data to kick-start hydration or to configure a widget. The usual answer is an inline `
```
You can parse it in your JavaScript application like this:
```js
import jsonFromScript from 'json-from-script';
// Parsed will be { foo: { bar: 'baz' } }
const parsed = jsonFromScript();
```
Behind the scenes the helper scans the DOM for matching script tags, reads their `data-*` attributes, and returns a single object that is ready to feed into your app state or view models.
## API
### `jsonFromScript(selector, attribute)`
Parses every script element that matches the given selector and merges the JSON contents into a single object keyed by a data attribute.
- `selector `: CSS selector for the script tags to parse. Defaults to `script.data` which targets `