# hexo-front-matter

> Front-matter parser.

Latest version **5.0.0** (published 2025-11-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install hexo-front-matter
pnpm add hexo-front-matter
yarn add hexo-front-matter
bun add hexo-front-matter
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2025-11-04 |
| First published | 2014-07-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=20.19.0 |
| Dependencies | 2 |
| Unpacked size | 18.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 23 |
| Author | Tommy Chen |
| Maintainers | ertrzyiks, abnerchou, tommy351, hexobot, jlhwung, tomap, curben, yoshinorin |
| Keywords | front-matter, front matter, yaml, yml, hexo, json |

## Links

- npm: https://www.npmjs.com/package/hexo-front-matter
- Repository: https://github.com/hexojs/hexo-front-matter
- Homepage: https://github.com/hexojs/hexo-front-matter#readme
- Issues: https://github.com/hexojs/hexo-front-matter/issues
- npm.io page: https://npm.io/package/hexo-front-matter

## Dependencies (2)

- [yaml](https://npm.io/package/yaml.md) 2.7.1
- [luxon](https://npm.io/package/luxon.md) ^3.6.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 5.0.0 (latest) — 2025-11-04
- 4.2.1 — 2023-10-31
- 4.2.0 — 2023-10-31
- 4.1.0 — 2023-04-20
- 4.0.0 — 2022-10-25
- 3.0.0 — 2022-01-03
- 2.0.0 — 2020-07-25
- 1.0.0 — 2019-08-30
- 0.2.3 — 2016-06-13
- 0.2.2 — 2015-02-11
- 0.2.1 — 2015-01-23
- 0.2.0 — 2015-01-23
- 0.1.0 — 2015-01-07
- 0.0.4 — 2014-07-23
- 0.0.3 — 2014-07-13
- … 2 more at https://npm.io/package/hexo-front-matter/versions

## README

# hexo-front-matter

[![CI](https://github.com/hexojs/hexo-front-matter/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/hexojs/hexo-front-matter/actions/workflows/ci.yml)
[![NPM version](https://badge.fury.io/js/hexo-front-matter.svg)](https://www.npmjs.com/package/hexo-front-matter)
[![Coverage Status](https://coveralls.io/repos/github/hexojs/hexo-front-matter/badge.svg)](https://coveralls.io/github/hexojs/hexo-front-matter)

Front-matter parser.

## What is Front-matter?

Front-matter allows you to specify data at the top of a file. Here are two formats:

**YAML front-matter**

```
---
layout: false
title: "Hello world"
---
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
```

**JSON front-matter**

```
;;;
"layout": false,
"title": "Hello world"
;;;
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
```

Prefixing separators are optional.

## API

### parse(str, [options])

Parses front-matter.

### stringify(obj, [options])

Converts an object to a front-matter string.

Option | Description | Default
--- | --- | ---
`mode` | The mode can be either `json` or `yaml`. | `yaml`
`separator` | Separator | `---`
`prefixSeparator` | Add prefixing separator. | `false`

### split(str)

Splits a YAML front-matter string.

### escape(str)

Converts hard tabs to soft tabs.

## License

MIT

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