https://github.com/yoannchb-pro/json-html
Convert json to html
https://github.com/yoannchb-pro/json-html
converter html json
Last synced: 2 months ago
JSON representation
Convert json to html
- Host: GitHub
- URL: https://github.com/yoannchb-pro/json-html
- Owner: yoannchb-pro
- License: mit
- Created: 2022-03-15T20:26:19.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-15T20:34:27.000Z (over 4 years ago)
- Last Synced: 2025-09-21T04:42:15.785Z (9 months ago)
- Topics: converter, html, json
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-into-html v1.0.0
Convert json to html
## Installation
```
npm i json-into-html
```
## Example
```js
const { Json2Html } = require('json-into-html');
const fs = require("fs");
const html = Json2Html([
{
name: "html",
content: [
{
name: 'head',
content: [
{
name: 'title',
content: "My title"
},
{
name: "style",
content: "body,html{ margin: 0; paddin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; flex-direction: column; color: #fff; font-familly: Arial, 'sans-serif'; background-color: #663399}"
}
]
},
{
name: 'body',
content: [
{
name: 'div',
content: [
{
name: 'img',
attr: {
src: 'https://upload.wikimedia.org/wikipedia/commons/d/d9/Flag_of_Canada_%28Pantone%29.svg',
class: 'test test2'
}
},
{
name: 'a',
content: 'click here',
attr: {
href: '#'
}
}
]
}
]
}
]
}
]);
fs.writeFileSync('index.html', html);
```
## Result
```html
My title
body,html{ margin: 0; paddin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; flex-direction: column; color: #fff; font-familly: Arial, 'sans-serif'; background-color: #663399}
```