# html-creator

> Generate HTML with node.js

Latest version **0.7.4** (published 2025-02-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-creator
pnpm add html-creator
yarn add html-creator
bun add html-creator
```

## Health

**Score 35/100 (D)** — status: stable.

Positive: no vulnerabilities.

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

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.7.4 |
| Published | 2025-02-11 |
| First published | 2017-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Johan Hargne |
| Maintainers | hargne |
| Keywords | html, build, generate, create, html-creator, node, node.js |

## Links

- npm: https://www.npmjs.com/package/html-creator
- Repository: https://github.com/Hargne/html-creator
- Homepage: https://github.com/Hargne/html-creator#readme
- Issues: https://github.com/Hargne/html-creator/issues
- npm.io page: https://npm.io/package/html-creator

## Dependencies (3)

- [mkdirp](https://npm.io/package/mkdirp.md) ^3.0.1
- [prettier](https://npm.io/package/prettier.md) ^2.4.1
- [@types/node](https://npm.io/package/@types/node.md) ^18.16.3

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.7.4 (latest) — 2025-02-11
- 0.7.3 — 2024-05-12
- 0.7.2 — 2023-12-15
- 0.8.0 — 2023-10-12
- 0.7.1 — 2023-07-13
- 0.7.0 — 2023-05-04
- 0.6.3 — 2023-03-29
- 0.6.2 — 2021-11-20
- 0.6.1 — 2021-11-12
- 0.6.0 — 2021-10-11
- 0.4.4 — 2020-02-17
- 0.4.3 — 2018-08-02
- 0.4.2 — 2018-02-26
- 0.4.1 — 2018-02-26
- 0.4.0 — 2018-02-26
- … 9 more at https://npm.io/package/html-creator/versions

## README

<p align="center">
  <h3 align="center">⚙️ html-creator</h3>

  <p align="center">
    Generate HTML with NodeJS
    <br>
    <a href="https://github.com/Hargne/html-creator/wiki"><strong>Documentation »</strong></a>
  </p>
</p>

## Installation

```shell
$ npm i html-creator
```

## Usage

```Javascript
const htmlCreator = require("html-creator");

const html = new htmlCreator([
  {
    type: "head",
    content: [
      {
        type: "title",
        content: "Generated HTML",
      },
      {
        type: "style",
        content: `
          #cool-text {
            color: red;
          }
        `,
      },
    ],
  },
  {
    type: "body",
    content: [
      {
        type: "div",
        content: [
          {
            type: "div",
            content: "This is a cool text 😎",
            attributes: { id: "cool-text" },
          },
          {
            type: "a",
            content: "Click here",
            attributes: { href: "/path-to-infinity", target: "_blank" },
          },
        ],
      },
    ],
  },
]);
const result = html.renderHTML();
```

The above code will result with the following HTML output:

```HTML
<!DOCTYPE html>
<html>
  <head>
    <title>Generated HTML</title>
    <style>
      #cool-text {
        color: red;
      }
    </style>
  </head>
  <body>
    <div>
      <div id="cool-text">This is a cool text 😎</div>
      <a href="/path-to-infinity" target="_blank">Click here</a>
    </div>
  </body>
</html>
```

Visit the **[wiki](https://github.com/Hargne/html-creator/wiki)** for more examples of usage, method reference and further reading.

# Wanna Contribute?

Do you believe that something is missing from this plugin or perhaps is not working as intended? Awesome-pants! Help is always appreciated.
Just be sure to read through the [Contributing Handbook](https://github.com/Hargne/html-creator/wiki/Contributing-Handbook) (and remember to have a jolly good time).

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