# estree-to-babel

> convert estree ast to babel

Latest version **12.0.1** (published 2026-03-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install estree-to-babel
pnpm add estree-to-babel
yarn add estree-to-babel
bun add estree-to-babel
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 12.0.1 |
| Published | 2026-03-04 |
| First published | 2018-12-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 1 |
| Unpacked size | 29 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 35 |
| Author | coderaiser |
| Maintainers | coderaiser |
| Keywords | ast, convert, estree, babel, espree |

## Links

- npm: https://www.npmjs.com/package/estree-to-babel
- Repository: https://github.com/coderaiser/estree-to-babel
- Homepage: http://github.com/coderaiser/estree-to-babel
- Issues: https://github.com/coderaiser/estree-to-babel/issues
- npm.io page: https://npm.io/package/estree-to-babel

## Dependencies (1)

- [@putout/babel](https://npm.io/package/@putout/babel.md) ^5.1.2

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 12.0.1 (latest) — 2026-03-04
- 12.0.0 — 2026-01-07
- 11.1.0 — 2025-09-09
- 11.0.3 — 2025-05-29
- 11.0.2 — 2025-04-08
- 11.0.1 — 2025-03-31
- 11.0.0 — 2025-03-31
- 10.5.0 — 2025-02-09
- 10.4.0 — 2025-02-09
- 10.3.0 — 2025-01-27
- 10.2.0 — 2025-01-21
- 10.1.0 — 2025-01-11
- 10.0.1 — 2024-11-06
- 10.0.0 — 2024-10-26
- 9.1.0 — 2024-07-27
- … 50 more at https://npm.io/package/estree-to-babel/versions

## README

# Estree-to-babel [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]

[NPMIMGURL]: https://img.shields.io/npm/v/estree-to-babel.svg?style=flat&longCache=true
[BuildStatusURL]: https://github.com/coderaiser/estree-to-babel/actions?query=workflow%3A%22Node+CI%22 "Build Status"
[BuildStatusIMGURL]: https://github.com/coderaiser/estree-to-babel/workflows/Node%20CI/badge.svg
[NPMURL]: https://npmjs.org/package/estree-to-babel "npm"
[BuildStatusURL]: https://travis-ci.org/coderaiser/estree-to-babel "Build Status"
[CoverageURL]: https://coveralls.io/github/coderaiser/estree-to-babel?branch=master
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/estree-to-babel/badge.svg?branch=master&service=github

Convert [`ESTree`](https://github.com/estree/estree)-compatible `JavaScript AST` to [`Babel AST`](https://github.com/babel/babel/blob/main/packages/babel-parser/ast/spec.md).

To use parsers like:

- [`acorn`](https://github.com/acornjs/acorn)
- [`cherow`](https://github.com/cherow/cherow)
- [`espree`](https://github.com/eslint/espree)
- etc...

With `babel` tools like:

- [`@babel/traverse`](https://babeljs.io/docs/en/babel-traverse)
- [`@babel/types`](https://babeljs.io/docs/en/babel-types)
- etc...

The thing is [`@babel/parser`](https://babeljs.io/docs/en/babel-parser) has a [little differences](https://babeljs.io/docs/en/babel-parser#output) with `estree` standard:

- `Property` of `ObjectExpression` and `ObjectPattern` called `ObjectProperty`;
- `FunctionExpression` of a `Property` located in `ObjectMethod` node;
- `File` node;
- `StringLiteral`, `NumericLiteral`, `NullLiteral`, `RegExpLiteral`, `BooleanLiteral` instead of `Literal`;
- `ClassMethod` instead of `MethodDefinition`;
- `ClassPrivateMethod`;
- `ClassPrivateName` stores name as `Identifier` in `id` field;
- `ClassPrivateProperty` instead of `FieldDefinition`;
- `OptionalMemberExpression` and `OptionalCallExpression` instead of `ChainExpression`;
- `ImportDeclaration` and `ExportNamedDeclaration` has `attributes`;
- `JSXText` has `extra` field;
- `extra.parenthesized=true` instead of `ParenthesizedExpression`;
- etc...

Also [`@babel/parser`](https://babeljs.io/docs/en/babel-parser) has differences with [`typescript-estree`](https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/typescript-estree):

- `ClassPrivateProperty` instead of `PropertyDefinition` when `key.type=PrivateName`;
- `ClasseProperty` instead of `PropertyDefinition` when `key.type=Identifier`;
- `PrivateName` instead of `PrivateIdentifier`;
- `TSQualifiedName` instead of `MemberExpression`  in `TSInterfaceHeritage`;
- `TSDeclaredMethod` with `abstract=true` instead of `TSAbstractMethodDefinition`;
- `extra.parenthesized=true` instead of `TSParenthesizedType`;
- etc...

`estree-to-babel` aims to smooth this differences.

## Install

```
npm i estree-to-babel
```

### Example

```js
import {parse} from 'cherow';
import {estreeToBabel} from 'estree-to-babel';
import {traverse} from '@babel/traverse';

const ast = estreeToBabel(parse(`
    const f = ({a}) => a;
`));

traverse({
    ObjectProperty(path) {
        console.log(path.value.name);
        // output
        'a';
    },
});
```

You can provide options:

```js
import * as cherow from 'cherow';
import {estreeToBabel} from 'estree-to-babel';
import traverse from '@babel/traverse';

const options = {
    convertParens: false,
};

const ast = estreeToBabel(cherow.parse(`
    (a = b)
`), options);

traverse({
    AssignmentExpression(path) {
        console.log(path.parentPath.type);
        // output
        'ParenthesizedExpression';
    },
});
```

## License

MIT

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