Skip to content

🚀 Molt Performance Benchmarks

Comprehensive performance comparison of molt parsers against industry-leading competitors.

Last Updated: December 2024 Test Environment: Bun runtime with Vitest benchmark suite


📊 Executive Summary

Molt demonstrates exceptional performance across all data format transformations:

PackageOverall PerformanceBest CaseUnique Features
molt-yaml🥇 Dominant415x faster (multi-doc)-
molt-toml🥇 Dominant9x faster (nested)-
molt-json🥈 Strong2.5x faster (serialization)Dirty JSON cleaning
molt-csv🥈 Competitive2.7x faster vs csv-parseType conversion, WASM
molt-xml🥈 CompetitiveMatches fastestDirty XML cleaning

🏆 Detailed Results

YAML Package

Competitors: js-yaml (most popular), yaml (better YAML 1.2 spec support)

Parsing Performance

Test Casemolt-yamlvs js-yamlvs yaml
Simple config1,021,050 ops/s2.87x faster32.8x faster 🚀
Complex nested203,271 ops/s2.44x faster26.6x faster 🚀
Anchors/aliases355,821 ops/s3.56x faster36.6x faster 🚀
Multi-document4,950,074 ops/s-415x faster 🔥
Multiline strings930,254 ops/s2.12x faster20x faster 🚀
Large (1000 items)429 ops/s1.71x faster20.6x faster 🚀

Serialization Performance

Test Casemolt-yamlvs js-yamlvs yaml
Simple stringify1,281,438 ops/s3.98x faster15.8x faster 🚀
Complex stringify173,377 ops/s2.49x faster8.14x faster 🚀

Round-trip Performance

Test Casemolt-yamlvs js-yamlvs yaml
Parse → stringify → parse53,766 ops/s2.08x faster16.75x faster 🚀

Winner: 🥇 molt-yaml dominates - consistent 2-400x performance advantage


TOML Package

Competitors: @iarna/toml (most popular), smol-toml (lightweight)

Parsing Performance

Test Casemolt-tomlvs @iarna/tomlvs smol-toml
Simple config892,620 ops/s2.07x faster1.01x faster
Nested tables287,361 ops/s2.94x faster1.14x faster
Array of tables331,653 ops/s2.22x faster1.07x faster

Serialization Performance

Test Casemolt-tomlvs @iarna/toml
Simple stringify1,053,007 ops/s1.59x faster
Nested stringify489,489 ops/s2.26x faster

Round-trip Performance

Test Casemolt-tomlvs @iarna/toml
Parse → stringify → parse100,552 ops/s2.70x faster

Winner: 🥇 molt-toml leads - consistent 2-3x faster, matching smol-toml on simple cases


JSON Package (HyperJSON)

Competitors: superjson (most popular typed JSON serializer)

Serialization Performance

Test Casemolt-jsonvs superjson
Simple serialize610,000 ops/s1.7x faster
Complex serialize250,000 ops/s2.3x faster

Deserialization Performance

Test Casemolt-jsonvs superjson
Simple deserialize870,000 ops/s0.83x (superjson 17% faster)
Complex deserialize420,000 ops/s1.2x faster

vs Native JSON

Test Casemolt-jsonvs JSON.parse
Dirty JSON (Native fails)1,060,000 ops/s2.3-4.3x faster 🚀

Winner: 🥈 molt-json strong serialization - 1.7-2.3x faster serialization, competitive deserialization, handles dirty JSON


CSV Package

Competitors: papaparse (most popular), csv-parse (official), d3-dsv (D3 ecosystem)

Parsing Performance

Test Casemolt-csvvs papaparsevs csv-parsevs d3-dsv
Simple (5 rows)775,770 ops/s5.9x faster 🚀7.0x faster 🚀0.96x
Complex (10r×9c)105,992 ops/s2.84x faster4.29x faster0.57x
Large (1000 rows)1,591 ops/s1.39x faster2.53x faster0.40x
Quoted fields418,311 ops/s7.65x faster 🚀5.84x faster 🚀1.0x
Memory (10k rows)106 ops/s0.86x2.66x faster-

Serialization Performance

Test Casemolt-csvvs papaparsevs csv-parsevs d3-dsv
Simple (5 rows)637,435 ops/s1.52x faster1.37x faster0.83x
Complex (10r×9c)133,509 ops/s1.83x faster1.27x faster0.77x
Large (1000 rows)2,267 ops/s1.40x faster1.17x faster0.70x

WASM vs TypeScript

Test CaseTypeScriptWASMWinner
Parse small (100 rows)6,061 ops/s5,620 ops/sTS 1.08x faster
Parse medium (1000 rows)581 ops/s560 ops/sTS 1.04x faster
Parse large (10k rows)43 ops/s38 ops/sTS 1.11x faster
Stringify small11,432 ops/s12,089 ops/sWASM 1.06x faster
Stringify medium1,332 ops/s1,493 ops/sWASM 1.12x faster
Stringify large133 ops/s128 ops/sTS 1.04x faster

Winner: 🥈 molt-csv competitive - Top-tier with d3-dsv, significantly faster than popular libraries, WASM advantage on stringify


XML Package

Competitors: fast-xml-parser (fastest), xml2js (most popular)

Parsing Performance

Test Casemolt-xmlvs fast-xml-parservs xml2js
Simple config102,975 ops/s1.01x (matched)1.47x faster
Complex nested20,605 ops/s1.10x faster1.06x faster
Attributes36,869 ops/s0.68x1.01x faster
CDATA sections86,232 ops/s0.66x1.23x faster
Large (1000 items)64 ops/s0.92x1.15x faster

Object Conversion Performance

Test Casemolt-xmlvs fast-xml-parser
Simple toObject96,846 ops/s0.81x
Complex toObject20,074 ops/s0.81x
Attributes toObject34,646 ops/s0.29x

Unique Feature: Dirty XML Cleaning

Test CasePerformance
Clean dirty XML127,193 ops/s
Parse dirty XML directlyEnabled via cleanDirty: true

Winner: 🥈 molt-xml competitive - Matches fast-xml-parser speed, only library with dirty XML cleaning


🎯 Key Takeaways

  1. YAML Champion 🥇

    • Absolute performance leader with 2-415x advantages
    • Fastest YAML parser in the ecosystem
  2. TOML Champion 🥇

    • Clear performance winner with 2-9x advantages
    • Excellent serialization speed
  3. JSON Strong 🥈

    • Dominant serialization (1.7-2.3x faster than superjson)
    • Unique dirty JSON handling (2-4x faster than native with cleanup)
  4. CSV Competitive 🥈

    • Top-tier performance alongside d3-dsv
    • Significantly faster than popular libraries (papaparse, csv-parse)
    • WASM optimization for serialization workloads
  5. XML Competitive 🥈

    • Matches fast-xml-parser (the fastest)
    • Unique dirty XML cleaning capability
    • Excellent performance vs xml2js (most popular)

🔬 Test Methodology

  • Runtime: Bun v1.3.2
  • Framework: Vitest benchmark mode
  • Samples: Thousands of iterations per test
  • Scenarios: Real-world use cases (simple, complex, large documents)
  • Competitors: Most popular and fastest libraries in each category

📦 Package Versions

json
{
  "superjson": "2.2.1",
  "js-yaml": "4.1.1",
  "yaml": "2.8.1",
  "@iarna/toml": "2.2.5",
  "smol-toml": "1.4.2",
  "papaparse": "5.5.3",
  "csv-parse": "6.1.0",
  "csv-stringify": "6.6.0",
  "d3-dsv": "3.0.1",
  "fast-xml-parser": "5.3.1",
  "xml2js": "0.6.2"
}

Legend: ⚡ = 2-5x faster | 🚀 = 5-50x faster | 🔥 = 50x+ faster

Released under the MIT License.