# yaml-eslint-parser

> A YAML parser that produces output compatible with ESLint

Latest version **2.1.0** (published 2026-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install yaml-eslint-parser
pnpm add yaml-eslint-parser
yarn add yaml-eslint-parser
bun add yaml-eslint-parser
```

## 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 | 2.1.0 |
| Published | 2026-07-08 |
| First published | 2020-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^20.19.0 \|\| ^22.13.0 \|\| >=24 |
| Dependencies | 2 |
| Unpacked size | 62.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 16 |
| Author | Yosuke Ota |
| Maintainers | ota-meshi |
| Keywords | yaml, eslint, parser |

## Links

- npm: https://www.npmjs.com/package/yaml-eslint-parser
- Repository: https://github.com/ota-meshi/yaml-eslint-parser
- Homepage: https://github.com/ota-meshi/yaml-eslint-parser#readme
- Issues: https://github.com/ota-meshi/yaml-eslint-parser/issues
- Funding: https://github.com/sponsors/ota-meshi
- npm.io page: https://npm.io/package/yaml-eslint-parser

## Dependencies (2)

- [yaml](https://npm.io/package/yaml.md) ^2.0.0
- [eslint-visitor-keys](https://npm.io/package/eslint-visitor-keys.md) ^5.0.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

- 2.1.0 (latest) — 2026-07-08
- 1.0.0 (next) — 2022-05-18
- 2.0.0 — 2026-01-17
- 1.3.2 — 2025-12-04
- 1.3.1 — 2025-11-25
- 1.3.0 — 2025-02-28
- 1.2.3 — 2024-05-25
- 1.2.2 — 2023-05-09
- 1.2.1 — 2023-05-07
- 1.2.0 — 2023-03-09
- 1.1.0 — 2022-07-28
- 1.0.1 — 2022-05-18
- 1.0.0-beta.1 — 2022-04-08
- 1.0.0-beta.0 — 2022-04-08
- 0.5.0 — 2021-11-06
- … 18 more at https://npm.io/package/yaml-eslint-parser/versions

## README

# yaml-eslint-parser

A YAML parser that produces output [compatible with ESLint](https://eslint.org/docs/developer-guide/working-with-custom-parsers#all-nodes).

_This parser is backed by excellent [yaml](https://github.com/eemeli/yaml) package and it is heavily inspired by [yaml-unist-parser](https://github.com/ikatyang/yaml-unist-parser) package._

[![NPM license](https://img.shields.io/npm/l/yaml-eslint-parser.svg)](https://www.npmjs.com/package/yaml-eslint-parser)
[![NPM version](https://img.shields.io/npm/v/yaml-eslint-parser.svg)](https://www.npmjs.com/package/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads&colorB=green&suffix=/day&query=$.downloads&uri=https://api.npmjs.org//downloads/point/last-day/yaml-eslint-parser&maxAge=3600)](http://www.npmtrends.com/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dw/yaml-eslint-parser.svg)](http://www.npmtrends.com/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dm/yaml-eslint-parser.svg)](http://www.npmtrends.com/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dy/yaml-eslint-parser.svg)](http://www.npmtrends.com/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dt/yaml-eslint-parser.svg)](http://www.npmtrends.com/yaml-eslint-parser)
[![Build Status](https://github.com/ota-meshi/yaml-eslint-parser/workflows/CI/badge.svg?branch=master)](https://github.com/ota-meshi/yaml-eslint-parser/actions?query=workflow%3ACI)
[![Coverage Status](https://coveralls.io/repos/github/ota-meshi/yaml-eslint-parser/badge.svg?branch=master)](https://coveralls.io/github/ota-meshi/yaml-eslint-parser?branch=master)

## Installation

```bash
npm install --save-dev yaml-eslint-parser
```

## Usage

### Configuration

Use `eslint.config.js` file to configure parser (ESLint v9+). See also: [https://eslint.org/docs/latest/use/configure/](https://eslint.org/docs/latest/use/configure/).

Example **eslint.config.js**:

```js
import * as yamlParser from "yaml-eslint-parser";

export default [
  {
    files: ["*.yaml", "*.yml"],
    languageOptions: {
      parser: yamlParser,
    },
  },
];
```

<details>
<summary>For ESLint v8 and earlier (.eslintrc.js)</summary>

```js
module.exports = {
  overrides: [
    {
      files: ["*.yaml", "*.yml"],
      parser: "yaml-eslint-parser",
    },
  ],
};
```

</details>

### Advanced Configuration

The following additional configuration options are available by specifying them in [parserOptions](https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options) in your ESLint configuration file.

Example **eslint.config.js**:

```js
import * as yamlParser from "yaml-eslint-parser";

export default [
  {
    files: ["*.yaml", "*.yml"],
    languageOptions: {
      parser: yamlParser,
      // Additional configuration options
      parserOptions: {
        defaultYAMLVersion: "1.2",
      },
    },
  },
];
```

<details>
<summary>For ESLint v8 and earlier (.eslintrc.js)</summary>

```js
module.exports = {
  overrides: [
    {
      files: ["*.yaml", "*.yml"],
      parser: "yaml-eslint-parser",
      // Additional configuration options
      parserOptions: {
        defaultYAMLVersion: "1.2",
      },
    },
  ],
};
```

</details>

#### `parserOptions.defaultYAMLVersion`

Set to `"1.2"` or `"1.1"`. Select the YAML version used by documents without a `%YAML` directive.  
If not specified, the [yaml](https://eemeli.org/yaml/)'s default `version` option (`"1.2"`) is used.  
See <https://eemeli.org/yaml/#document-options> for details.

## Usage for Custom Rules / Plugins

- [AST.md](./docs/AST.md) is AST specification.
- [block-mapping.ts](https://github.com/ota-meshi/eslint-plugin-yml/blob/master/src/rules/block-mapping.ts) is an example.
- You can see the AST on the [Online DEMO](https://ota-meshi.github.io/yaml-eslint-parser/).

## Usage for Directly

Example:

```ts
import type { AST } from "yaml-eslint-parser";
import { parseYAML, getStaticYAMLValue } from "yaml-eslint-parser";

const code = `
american:
  - Boston Red Sox
  - Detroit Tigers
  - New York Yankees
national:
  - New York Mets
  - Chicago Cubs
  - Atlanta Braves
`;

const ast: AST.YAMLProgram = parseYAML(code);
console.log(ast);

const value = getStaticYAMLValue(ast);
console.log(value);
```

## Related Packages

- [eslint-plugin-jsonc](https://github.com/ota-meshi/eslint-plugin-jsonc) ... ESLint plugin for JSON, JSON with comments (JSONC) and JSON5.
- [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) ... ESLint plugin for YAML.
- [eslint-plugin-toml](https://github.com/ota-meshi/eslint-plugin-toml) ... ESLint plugin for TOML.
- [eslint-plugin-json-schema-validator](https://github.com/ota-meshi/eslint-plugin-json-schema-validator) ... ESLint plugin that validates data using JSON Schema Validator.
- [jsonc-eslint-parser](https://github.com/ota-meshi/jsonc-eslint-parser) ... JSON, JSONC and JSON5 parser for use with ESLint plugins.
- [toml-eslint-parser](https://github.com/ota-meshi/toml-eslint-parser) ... TOML parser for use with ESLint plugins.

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