# jshiki

> Lightweight expression evaluation library for Node.js

Latest version **4.0.1** (published 2025-12-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install jshiki
pnpm add jshiki
yarn add jshiki
bun add jshiki
```

## Health

**Score 65/100 (B)** — status: stable.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2025-12-22 |
| First published | 2015-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=24.0 |
| Dependencies | 1 |
| Unpacked size | 83 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Adaline Valentina Simonian |
| Maintainers | adalinesimonian |
| Keywords | expression, javascript, js, parser, eval, evaluation, evaluator, execution, safe, secure, small, scope, context, runtime, AST, acorn |

## Links

- npm: https://www.npmjs.com/package/jshiki
- Repository: https://github.com/adalinesimonian/jshiki
- Homepage: https://jshiki.io
- Funding: https://github.com/sponsors/adalinesimonian
- npm.io page: https://npm.io/package/jshiki

## Dependencies (1)

- [acorn](https://npm.io/package/acorn.md) ^8.15.0

## 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

- 4.0.1 (latest) — 2025-12-22
- 4.0.0 — 2025-12-04
- 3.4.0 — 2021-09-10
- 3.3.0 — 2021-09-08
- 3.2.0 — 2021-08-29
- 3.1.0 — 2021-08-27
- 3.0.0 — 2021-08-20
- 2.1.0 — 2021-08-17
- 2.0.0 — 2021-08-13
- 1.1.1 — 2021-05-19
- 1.1.0 — 2017-07-04
- 1.0.0 — 2017-06-29
- 0.0.3 — 2015-09-14
- 0.0.2 — 2015-09-07
- 0.0.1 — 2015-09-07

## README

![j式 — jshiki](assets/logo/jshiki-readme-banner.svg)

<h2 align="center">Safe and Easy Expression Evaluation for Node.js</h2>

<p align="center">
  <a href="https://github.com/adalinesimonian/jshiki/actions/workflows/main-test.yml"><img alt="Build Status" src="https://github.com/adalinesimonian/jshiki/actions/workflows/main-test.yml/badge.svg?branch=main" /></a>
  <a href="https://app.codecov.io/gh/adalinesimonian/jshiki"><img alt="Codecov Coverage Status" src="https://codecov.io/gh/adalinesimonian/jshiki/branch/main/graph/badge.svg?token=SrIwZvl2YA" /></a>
  <a href="https://www.npmjs.com/package/jshiki"><img alt="npm Version" src="https://img.shields.io/npm/v/jshiki.svg" /></a>
</p>

<p align="center">
  <strong><a href="https://jshiki.io/latest/user-guide/">Documentation</a></strong> |
  <strong><a href="https://github.com/adalinesimonian/jshiki/blob/main/CHANGELOG.md">Change Log</a></strong>
</p>

---

jshiki provides a safe and easy way to evaluate expressions without worrying about external data being overwritten or accessed in unexpected ways. jshiki only has one lightweight dependency, [acorn], which it uses to parse expressions.

> **IMPORTANT!** jshiki is not a true sandbox. If you need to be able to evaluate arbitrary code of unknown origin, you may want to consider using [vm2] or a similar library.

### Basic Usage

```js
import * as jshiki from 'jshiki'

let result = jshiki.evaluate('(5 + 7) / 3') // result => 4
// or
let expression = jshiki.parse('(5 + 7) / 3')
result = expression() // result => 4
```

### Accessing data

```js
const code = "`Hello! My name's ${name.trim()}`"

expression = jshiki.parse(code)
result = expression({ name: ' Azumi ' })
// result => "Hello! My name's Azumi"

// or
result = jshiki.evaluate(code, {
  scope: { name: ' Azumi ' },
})
// result => "Hello! My name's Azumi"
```

### Asynchronous evaluation

```js
const asyncCode = "`I'm ${await status()}...`"

expression = jshiki.parseAsync(asyncCode)
result = await expression({
  status: async () => 'waiting',
})
// result => "I'm waiting..."

// or
result = await jshiki.evaluateAsync(asyncCode, {
  scope: { status: async () => 'waiting' },
})
// result => "I'm waiting..."
```

For more examples, features, and information on how to use jshiki, see the [documentation].

## Discussion

Discuss jshiki on [GitHub discussions]. Make sure to follow the [code of conduct].

## Contributing

If you're looking for a way to contribute to jshiki, see the [contribution guide].

## Licence

[MIT](LICENCE)

[acorn]: https://github.com/acornjs/acorn
[vm2]: https://github.com/patriksimek/vm2
[documentation]: https://jshiki.io/latest/user-guide/
[github discussions]: https://github.com/adalinesimonian/jshiki/discussions
[code of conduct]: CODE_OF_CONDUCT.md
[contribution guide]: CONTRIBUTING.md

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