# unplugin-yaml

> Allow importing YAML files as JSON or Strings

Latest version **4.3.1** (published 2026-10-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install unplugin-yaml
pnpm add unplugin-yaml
yarn add unplugin-yaml
bun add unplugin-yaml
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.3.1 |
| Published | 2026-10-16 |
| First published | 2023-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=22 |
| Dependencies | 3 |
| Unpacked size | 19.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 6 |
| Author | Lucas Nørgård |
| Maintainers | luxass |
| Keywords | astro, esbuild, nuxt, rolldown, rolldown-plugin, rollup, rollup-plugin, unplugin, vite, vite-plugin, webpack, yaml |

## Links

- npm: https://www.npmjs.com/package/unplugin-yaml
- Repository: https://github.com/luxass/unplugin-yaml
- Issues: https://github.com/luxass/unplugin-yaml/issues
- npm.io page: https://npm.io/package/unplugin-yaml

## Dependencies (3)

- [yaml](https://npm.io/package/yaml.md) 2.9.1
- [unplugin](https://npm.io/package/unplugin.md) 3.4.0
- [@rollup/pluginutils](https://npm.io/package/@rollup/pluginutils.md) 5.4.0

## Alternatives

- [monaco-yaml](https://npm.io/package/monaco-yaml.md) — 420.1K weekly downloads
- [@crewx/workflow](https://npm.io/package/@crewx/workflow.md) — 3.1K weekly downloads
- [yaml-cat](https://npm.io/package/yaml-cat.md) — 38 weekly downloads
- [nunjucks-in-yaml](https://npm.io/package/nunjucks-in-yaml.md) — 9 weekly downloads
- [shopify-symlinks](https://npm.io/package/shopify-symlinks.md) — 3 weekly downloads

## Recent versions

- 4.3.1 (latest) — 2026-10-16
- 4.3.0 — 2026-09-19
- 4.2.1 — 2026-06-14
- 4.2.0 — 2026-04-26
- 4.1.0 — 2026-03-27
- 4.0.1 — 2026-03-14
- 4.0.0 — 2026-02-15
- 3.0.7 — 2025-10-27
- 3.0.6 — 2025-09-13
- 3.0.5 — 2025-08-29
- 3.0.4 — 2025-08-04
- 3.0.3 — 2025-08-01
- 3.0.2 — 2025-07-15
- 3.0.1 — 2025-07-03
- 3.0.0 — 2025-05-11
- … 20 more at https://npm.io/package/unplugin-yaml/versions

## README

# unplugin-yaml

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]

Allow import YAML file for Vite, Webpack, Rollup and esbuild. With TypeScript support. Powered by [unplugin](https://github.com/unjs/unplugin).

## Install

```bash
npm i -D unplugin-yaml
```

## Usage

> [!TIP]
> You can view all examples [here](./examples).

<details>
<summary>Vite</summary><br/>

```ts
// vite.config.ts
import YAMLPlugin from "unplugin-yaml/vite";

export default defineConfig({
  plugins: [YAMLPlugin({/* options */})],
});
```

<br/></details>

<details>
<summary>Rollup</summary><br/>

```ts
// rollup.config.js
import YAMLPlugin from "unplugin-yaml/rollup";

export default {
  plugins: [YAMLPlugin({/* options */})],
};
```

<br/></details>

<details>
<summary>Webpack</summary><br/>

```ts
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [require("unplugin-yaml/webpack").default({/* options */})],
};
```

<br/></details>

<details>
<summary>Nuxt</summary><br/>

```ts
// nuxt.config.js
export default defineNuxtConfig({
  modules: [["unplugin-yaml/nuxt", {/* options */}]],
});
```

<br/></details>

<details>
<summary>Astro</summary><br/>

```ts
// astro.config.mjs
import { defineConfig } from "astro/config";
import YAMLPlugin from "unplugin-yaml/astro";

// https://astro.build/config
export default defineConfig({
  integrations: [YAMLPlugin({/* options */})],
});
```

<br/></details>

<details>
<summary>esbuild</summary><br/>

```ts
// esbuild.config.js
import { build } from "esbuild";
import YAMLPlugin from "unplugin-yaml/esbuild";

build({
  /* ... */
  plugins: [YAMLPlugin({/* options */})],
});
```

<br/></details>

<details>
<summary>Rspack</summary><br/>

```ts
// rspack.config.mjs
import rspack from "@rspack/core";
import YAMLPlugin from "unplugin-yaml/rspack";

/** @type {import('@rspack/core').Configuration} */
export default {
  plugins: [
    new rspack.HtmlRspackPlugin({
      template: "./index.html",
    }),
    YAMLPlugin(),
  ],
};
```

<br/></details>

<details>
<summary>Rolldown (Experimental)</summary><br/>

```ts
// rolldown.config.js
import { defineConfig } from "rolldown";
import YAMLPlugin from "unplugin-yaml/rolldown";

export default defineConfig({
  input: "./index.js",
  plugins: [YAMLPlugin({/* options */})],
});
```

<br/></details>

## Configuration

```ts
YAMLPlugin({
  include: [
    /\.yamlcustom$/, // .yamlcustom
  ],
  parserOptions: {
    // see yaml load options
  },
});
```

### TypeScript

If you are using TypeScript, you need to add the following to your `tsconfig.json` file:

```json
{
  "compilerOptions": {
    "types": ["unplugin-yaml/types"]
  }
}
```

## 📄 License

Published under [MIT License](./LICENSE).

[npm-version-src]: https://img.shields.io/npm/v/unplugin-yaml?style=flat&colorA=18181B&colorB=4169E1
[npm-version-href]: https://npmjs.com/package/unplugin-yaml
[npm-downloads-src]: https://img.shields.io/npm/dm/unplugin-yaml?style=flat&colorA=18181B&colorB=4169E1
[npm-downloads-href]: https://npmjs.com/package/unplugin-yaml

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