{"id":19460383,"url":"https://github.com/haensl/embed-json","last_synced_at":"2026-05-09T09:37:36.710Z","repository":{"id":30534140,"uuid":"125264412","full_name":"haensl/embed-json","owner":"haensl","description":"Node.js module to embed JSON data from files into html.","archived":false,"fork":false,"pushed_at":"2023-01-11T18:30:40.000Z","size":127,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-08T23:19:17.887Z","etag":null,"topics":["embed","html","inline","inline-json","json","json-data","json-files","json-schema","minify"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haensl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["haensl"]}},"created_at":"2018-03-14T19:36:43.000Z","updated_at":"2021-11-14T11:41:16.000Z","dependencies_parsed_at":"2023-01-14T17:09:59.412Z","dependency_job_id":null,"html_url":"https://github.com/haensl/embed-json","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haensl%2Fembed-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haensl%2Fembed-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haensl%2Fembed-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haensl%2Fembed-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haensl","download_url":"https://codeload.github.com/haensl/embed-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240664857,"owners_count":19837624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embed","html","inline","inline-json","json","json-data","json-files","json-schema","minify"],"created_at":"2024-11-10T17:36:51.436Z","updated_at":"2026-05-09T09:37:36.674Z","avatar_url":"https://github.com/haensl.png","language":"JavaScript","funding_links":["https://github.com/sponsors/haensl"],"categories":[],"sub_categories":[],"readme":"# embed-json\nNode.js module to inline/embed JSON data from files into html.\n\n[![NPM](https://nodei.co/npm/embed-json.png?downloads=true)](https://nodei.co/npm/embed-json/)\n\n[![npm version](https://badge.fury.io/js/embed-json.svg)](http://badge.fury.io/js/embed-json)\n\n[![CircleCI](https://circleci.com/gh/haensl/embed-json.svg?style=svg)](https://circleci.com/gh/haensl/embed-json)\n\n## Installation\n\n### NPM\n  `npm i --save embed-json`\n\n### Yarn\n  `yarn add embed-json`\n\n## Usage\n\n### Synopsis\n\n```javascript\nembedJson(htmlString, options);\n```\n\nEmbed JSON data from referenced files into the given HTML string.\n\nWhen `embedJson()` encounters a script tag with JSON mime type and a src attribute with `htmlString`, e.g.\n```html\n\u003cscript type=\"application/json\" src=\"data.json\"\u003e\u003c/script\u003e\n```\nit will retrieve the data from the file `src` and embed it into the tag. The `src` attribute is removed during this operation.\n\n\n### Example\n\n```javascript\nconst embedJson = require('embed-json');\nconst fs = require('fs');\n\nconst html = fs.readFileSync('index.html', 'utf8');\nconst htmlWithEmbeddedJSON = embedJson(html);\n// script tags with src attribute in index.html\n// \u003cscript type=\"application/json\" src=\"data.json\"\u003e\u003c/script\u003e\n// are transformed to\n// \u003cscript type=\"application/json\"\u003e{dataThat:'was in data.json'}\u003c/script\u003e\n```\n\n### Options\n\n### encoding `string`\n\n**Default:** `utf8`\n\nSpecify the [encoding](https://stackoverflow.com/a/14551669/5061949) of the JSON files.\n\n### mimeTypes `Array\u003cstring\u003e | string`\n\n**Default:** `['application/json', 'application/ld+json']`\n\nSpecify the mime type(s) of scripts to embed.\n\n### minify `boolean`\n\n**Default:** `true`\n\nSpecify whether or not to minify the embedded JSON data.\n\n### root `string`\n\n**Default:** [`path.dirname(require.main.filename)`](https://stackoverflow.com/a/18721515/5061949) _(i.e. a best guess at the project root.)_\n\nSpecify the root directory from which to resolve relative `src`s.\n\n### [Changelog](CHANGELOG.md)\n\n### [License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaensl%2Fembed-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaensl%2Fembed-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaensl%2Fembed-json/lists"}