# json-data-uri

> Parse and encode (plain or Base64) data URIs with JSON content and correct MIME type.

Latest version **0.2.0** (published 2022-11-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install json-data-uri
pnpm add json-data-uri
yarn add json-data-uri
bun add json-data-uri
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2022-11-18 |
| First published | 2022-11-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | M.K. |
| Maintainers | mk-pmb |
| Keywords | base64, data URI, data URL, JSON |

## Links

- npm: https://www.npmjs.com/package/json-data-uri
- Repository: https://github.com/mk-pmb/json-data-uri-js
- Homepage: https://github.com/mk-pmb/json-data-uri-js/#readme
- Issues: https://github.com/mk-pmb/json-data-uri-js/issues
- npm.io page: https://npm.io/package/json-data-uri

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.2.0 (latest) — 2022-11-18
- 0.1.0 — 2022-11-18

## README

<!--#echo json="package.json" key="name" underline="=" -->
json-data-uri
=============
<!--/#echo -->

<!--#echo json="package.json" key="description" -->
Parse and encode (plain or Base64) data URIs with JSON content and correct
MIME type.
<!--/#echo -->



API
---

This module exports an object that holds these functions:

### parse(uri)

Try to parse JSON data from a data URI given as string `uri`.
Returns decoded data, or `undefined` if there was an error.


### toPlainUri(data)

Convert JSON-able `data` to a plain text data: URI.
Returns a URI as a string.
With bad input, the content part of the URI will be broken.


### toBase64Uri(data)

Convert JSON-able `data` to a base64-encoded data: URI.
Returns a URI as a string.
With bad input, the content part of the URI will be broken.





Usage
-----

see [test/usage.mjs](test/usage.mjs).


<!--#toc stop="scan" -->



Known issues
------------

* Needs more/better tests and docs.




&nbsp;


License
-------
<!--#echo json="package.json" key=".license" -->
ISC
<!--/#echo -->

---
_Source: https://npm.io/package/json-data-uri · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
