# astro-html-beautifier

> Beautify html files on astro final bundle with js-beautify

Latest version **1.0.5** (published 2026-04-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install astro-html-beautifier
pnpm add astro-html-beautifier
yarn add astro-html-beautifier
bun add astro-html-beautifier
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2026-04-15 |
| First published | 2022-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | bangkitdev |
| Maintainers | bangkitwijanarko |
| Keywords | astro, astro-component, withastro, astro-integration, renderer, optimization, beautify, html |

## Links

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

## Dependencies (3)

- [blob](https://npm.io/package/blob.md) ^0.1.0
- [chalk](https://npm.io/package/chalk.md) ^5.6.2
- [js-beautify](https://npm.io/package/js-beautify.md) ^1.14.6

## 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

- 1.0.5 (latest) — 2026-04-15
- 1.0.4 — 2022-11-02
- 1.0.3 — 2022-10-21
- 1.0.2 — 2022-10-21
- 1.0.1 — 2022-10-21
- 1.0.0 — 2022-10-21

## README

# 🚀 Astro HTML Beautifier

Beautify html files on astro final bundle with [js-beautify][js-beautify]

## Installation

### Quick Install

Using `astro add` cli

```bash
npx astro add astro-html-beautifier
```

### Manual Install

```bash
npm i -D astro-html-beautifier
```

```js
import htmlBeautifier from 'astro-html-beautifier';

export default {
  // ...
  integrations: [htmlBeautifier()]
};
```

> **Note**
>
> if you leave the options blank, they will be overriden by default options

### Default Options

```js

const defaultConfig = {
    indent_size: 4,
    indent_char: "\t",
    max_preserve_newlines: -1,
    preserve_newlines: false,
    keep_array_indentation: false,
    break_chained_methods: false,
    indent_scripts: "keep",
    brace_style: "collapse",
    space_before_conditional: false,
    unescape_strings: false,
    jslint_happy: false,
    end_with_newline: false,
    wrap_line_length: 0,
    indent_inner_html: false,
    comma_first: false,
    e4x: false,
    indent_empty_lines: false,
}
```

## Usage

This integration automatically formats html files under the `/dist` folder by default, or the `outDir` directory in the `astro.config.mjs`.

## Configuration

```js
export default defineConfig({
  integrations: [
    htmlBeautifier({
        indent_size: 4,
        brace_style: "collapse",
        ...
    })
  ]
});
```

### Available Options

Here are the options, allowed to be passed through the config:

```ts
export  type beautifyOptions = {
    indent_size?: number;
    indent_char?: string;
    indent_with_tabs?: boolean;
    editorconfig?: boolean;
    eol?: string;
    end_with_newline?: boolean;
    indent_level?: number;
    preserve_newlines?: boolean;
    max_preserve_newlines?: number;
    space_in_paren?: boolean;
    space_in_empty_paren?: boolean;
    jslint_happy?: boolean;
    space_after_anon_function?: boolean;
    space_after_named_function?: boolean;
    brace_style?: "collapse"|"expand"|"end-expand"|"none";
    unindent_chained_methods?: boolean;
    break_chained_methods?: boolean;
    keep_array_indentation?: boolean;
    unescape_strings?: boolean;
    wrap_line_length?: number;
    e4x?: boolean;
    comma_first?: boolean;
    operator_position?: "before-newline"|"after-newline"|"preserve-newline";
    indent_empty_lines?: boolean;
    templating?: any;
};
```

Please learn more about the options in the [js-beautify][js-beautify] docs.

## Acknowledgements

- [js-beautify][js-beautify]

[js-beautify]:https://github.com/beautify-web/js-beautify

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