Plate I

No. 0.1.0v0.1.0 is out, with zero dependencies

Parse any JavaScript stack trace, from any runtime.

stacktern turns error.stack text from V8, SpiderMonkey and JavaScriptCore into clean, typed frames. Async, eval, native and WebAssembly frames included. Print them back or apply source maps, all in 4.6 kB.

Pack it: npm i stacktern { c.done ? T.copied : '' }
  • Zero dependencies
  • Faster than the usual parsers
  • Checked against V8 CallSite data

Field sample collected from error.stack

{ heroSamples[h.k].engine }stamp another engine

  1. No. { i + 1 } { f.functionName || T.anonymous } { shortLoc(f) } { g }

Observed habitats:

  • NodeV8
  • ChromeV8
  • DenoV8
  • EdgeV8
  • BunJSC
  • SafariJSC
  • FirefoxSpiderMonkey
  • React NativeHermes

Plate II

Playground

Paste a stack. Get frames.

Pick a sample from any engine, paste your own trace or capture one from this browser. The page runs the same code you install from npm.

Sample
  • { s.engine }{ s.label }{ s.source }
Field sample{ lineCount(p.input) } lines

Point at a label to find its line in the sample.

{ result(p.input, p.rt).frames.length } frames, { result(p.input, p.rt).ms } ms

No frames yet

Paste a stack trace or pick a sample to see its frames here.

  1. No. { i + 1 } { f.functionName || T.anonymous }
    File
    { f.fileName || '' }
    Line
    { f.lineNumber === null ? '' : f.lineNumber }
    Col
    { f.columnNumber === null ? '' : f.columnNumber }
    { g } eval from { originText(f) }

Everything runs locally in your browser. Nothing you paste leaves this page.

Plate III

Features

Built for the stacks you actually get

Real stacks are messy: async hops, eval code, builtins, Windows paths and bundler URLs. stacktern reads all of them and tells you what each frame is.

Fig. 1

Every engine, one frame shape

V8 in Node, Chrome, Deno and Edge, SpiderMonkey in Firefox, JavaScriptCore in Safari and Bun. The format is detected from the text, so a Safari trace parses fine on your Node server.

Fig. 2

Eval origins, kept

Code from eval and new Function keeps the full chain of where it was created, even eval inside eval.

Fig. 3

Messy paths are fine

Spaces and parentheses in paths, ports and query strings, webpack, blob, data and node: URLs, WebAssembly offsets.

  • C:\Users\me\app (copy)\a.js:3:9
  • http://localhost:8080/app.js?v=3:10:5
  • webpack:///./src/index.ts:7:1
  • blob:https://x.dev/9f1c:1:40
  • node:internal/timers:581:17
  • wasm://wasm/0019bd3a:wasm-function[12]:0x4f2

Fig. 4

Print it back, in any format

format turns frames back into stack text for V8, SpiderMonkey or JavaScriptCore. Try it:

Fig. 5

Source maps built in

mapFrames takes any resolver, and createSourceMapResolver reads v3 maps, including index maps with sections. No extra package.

Fig. 6

Tiny and typed

No dependencies, ESM and CommonJS builds, hand written TypeScript types.

Plate IV

Quick start

From text to frames in three lines

Pass an Error or a string. You get an array of plain objects with the same fields for every engine.

  1. i.Works on stacks from logs and crash reports, not only live errors
  2. ii.Unknown lines are skipped, never thrown on
  3. iii.Every frame keeps its raw line for display
import { parse } from 'stacktern';

try {
  await loadConfig();
} catch (error) {
  for (const frame of parse(error)) {
    console.log(frame.functionName, frame.fileName, frame.lineNumber);
  }
}

// Strings work too, from any engine:
parse('load@https://app.dev/main.js:12:5');
// [{ functionName: 'load', fileName: 'https://app.dev/main.js',
//    lineNumber: 12, columnNumber: 5, isNative: false, ... }]

Plate V

Benchmarks

Fast, and right more often

Measured on the same corpus of 71 real and documented stacks, with error-stack-parser and stacktrace-parser installed side by side.

4.0xfaster than error-stack-parser on a Node stack
100%field accuracy on the shared corpus
4.4xfaster source map lookups than node:module
Fig. 7 Parsing speed

Operations per second, higher is better. Median of 7 runs on Node 24.16.0, Windows 10, Ryzen 7 7800X3D.

One Node stack
V8 corpus, 35 stacks
Firefox and Safari, 7 stacks
Whole corpus, 71 stacks
Fig. 8 Accuracy

Share of frame fields that match the expected frames, over 44 stacks and 200 frames.

Fig. 9 Source map lookups

Key to related species

How it compares
Featurestackternerror-stack-parser 2.1.4stacktrace-parser 0.1.11
V8, SpiderMonkey and JavaScriptCore formatsyesyesyes
Flags for async, native, eval and new framesyesnono
Keeps builtin frames such as Promise.allyesnopartial
Paths with parenthesesyesnoyes
WebAssembly frames with positionsyespartialno
Eval origin chainyesnono
Prints stacks backyesnono
Source map resolveryesnono
TypeScript typesyesyesyes
Runtime dependencies011

Checked by running each package on the same inputs, see bench/accuracy.mjs in the repository.

Plate VI

Size and support

Small enough to ship everywhere

Minified with Bun, compressed with zlib. Import only parse and parseFrame and your bundler drops the rest.

Bundle size

Everything4.6 kB gzip12.0 kB min, 4.1 kB brotli
parse and parseFrame only2.3 kB gzip5.6 kB min, 2.1 kB brotli

Runtimes

  • Node 18, 20, 22, 24Tested in CI on Linux, plus Windows and macOS on 24.
  • BunThe full test suite passes on Bun.
  • DenoTested in CI.
  • BrowsersAny ES2019 browser: Chrome 73, Firefox 67, Safari 12.1 and later.

Plate VII

FAQ

Questions, answered

Short answers to what people ask first. The README has the details.

Yes. The format is detected from the text, not from the runtime the code runs in.

Give your error reports real frames

Install it in a second, parse stacks from any engine, and keep your crash reports readable.