# @textlint/markdown-to-ast

> Parse Markdown to AST with location info.

Latest version **15.8.0** (published 2026-08-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @textlint/markdown-to-ast
pnpm add @textlint/markdown-to-ast
yarn add @textlint/markdown-to-ast
bun add @textlint/markdown-to-ast
```

## Health

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

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 15.8.0 |
| Published | 2026-08-01 |
| First published | 2018-01-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 46.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 3198 |
| Author | azu |
| Maintainers | azu, textlint-user |

## Links

- npm: https://www.npmjs.com/package/@textlint/markdown-to-ast
- Repository: https://github.com/textlint/textlint
- Homepage: https://github.com/textlint/textlint/tree/master/packages/@textlint/markdown-to-ast/
- Issues: https://github.com/textlint/textlint/issues
- npm.io page: https://npm.io/package/@textlint/markdown-to-ast

## Dependencies (10)

- [debug](https://npm.io/package/debug.md) ^4.4.3
- [unified](https://npm.io/package/unified.md) ^9.2.2
- [remark-gfm](https://npm.io/package/remark-gfm.md) ^1.0.0
- [neotraverse](https://npm.io/package/neotraverse.md) ^0.6.18
- [remark-parse](https://npm.io/package/remark-parse.md) ^9.0.0
- [remark-footnotes](https://npm.io/package/remark-footnotes.md) ^3.0.0
- [structured-source](https://npm.io/package/structured-source.md) ^4.0.0
- [remark-frontmatter](https://npm.io/package/remark-frontmatter.md) ^3.0.0
- [@textlint/ast-node-types](https://npm.io/package/@textlint/ast-node-types.md) 15.8.0
- [mdast-util-gfm-autolink-literal](https://npm.io/package/mdast-util-gfm-autolink-literal.md) ^0.1.3

## Recent versions

- 15.8.0 (latest) — 2026-08-01
- 13.4.2-next.0 (next) — 2024-02-02
- 12.0.0-beta.3 (beta) — 2021-05-24
- 6.1.0-alpha.0f2fd6f9 (canary) — 2018-07-16
- 15.7.1 — 2026-05-18
- 15.7.0 — 2026-05-14
- 15.6.1 — 2026-05-11
- 15.6.0 — 2026-04-26
- 15.5.4 — 2026-04-09
- 15.5.2 — 2026-02-21
- 15.5.1 — 2026-01-19
- 15.5.0 — 2025-12-07
- 15.4.1 — 2025-12-03
- 15.4.0 — 2025-11-17
- 15.3.0 — 2025-11-10
- … 93 more at https://npm.io/package/@textlint/markdown-to-ast/versions

## README

# @textlint/markdown-to-ast

Parse Markdown to AST with location info.

This library is not parser itself, it dependent on [wooorm/remark](https://github.com/wooorm/remark).

> Markdown -> remark -> markdown-to-ast -> `TxtNode`s

The AST consists of `TxtNode`s.
A `TxtNode` of the AST has following properties:

- `loc` - Nodes have line and column-based location info.
- `range` - Nodes have an index-based location range (array).
- `raw` - Node have a `raw` text.
- `value` - Node have a `value` of text.

The interface are defined in [textlint/txtnode.md](https://github.com/textlint/textlint/blob/master/docs/txtnode.md "textlint/txtnode.md at master · textlint/textlint")

This library is a part of [textlint/textlint](https://github.com/textlint/textlint "textlint/textlint").

**If you need to markdown parser, please use [wooorm/remark](https://github.com/wooorm/remark) directly.**

## DEMO

- [textlint AST explorer](https://textlint.org/astexplorer/ "textlint AST explorer")

## Installation

```
npm install @textlint/markdown-to-ast
```

## Usage

```sh
var parse = require("@textlint/markdown-to-ast").parse;
var markdown = "It's a *text*";
var AST = parse(markdown);
/*
{
    "type": "Document",
    "children": [
        {
            "type": "Paragraph",
            "children": [
                {
                    "type": "Str",
                    "value": "It's a ",
                    "loc": {
                        "start": {
                            "line": 1,
                            "column": 0
                        },
                        "end": {
                            "line": 1,
                            "column": 7
                        }
                    },
                    "range": [
                        0,
                        7
                    ],
                    "raw": "It's a "
                },
                {
                    "type": "Emphasis",
                    "children": [
                        {
                            "type": "Str",
                            "value": "text",
                            "loc": {
                                "start": {
                                    "line": 1,
                                    "column": 8
                                },
                                "end": {
                                    "line": 1,
                                    "column": 12
                                }
                            },
                            "range": [
                                8,
                                12
                            ],
                            "raw": "text"
                        }
                    ],
                    "loc": {
                        "start": {
                            "line": 1,
                            "column": 7
                        },
                        "end": {
                            "line": 1,
                            "column": 13
                        }
                    },
                    "range": [
                        7,
                        13
                    ],
                    "raw": "*text*"
                }
            ],
            "loc": {
                "start": {
                    "line": 1,
                    "column": 0
                },
                "end": {
                    "line": 1,
                    "column": 13
                }
            },
            "range": [
                0,
                13
            ],
            "raw": "It's a *text*"
        }
    ],
    "loc": {
        "start": {
            "line": 1,
            "column": 0
        },
        "end": {
            "line": 1,
            "column": 13
        }
    },
    "range": [
        0,
        13
    ],
    "raw": "It's a *text*"
}
*/
```

If you want to know real use-case, please see [textlint/textlint](https://github.com/textlint/textlint "textlint/textlint").

## Tests

```
npm test
```

### Create fixtures

See [tools/](tools/) directory.

## Contributing

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D

## License

MIT

---
_Source: https://npm.io/package/@textlint/markdown-to-ast · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
