Skip to content

Getting Started with Molt โ€‹

Welcome to Molt, the high-performance data transformation stack! This guide will help you understand what Molt is and why you should use it.

What is Molt? โ€‹

Molt is a comprehensive suite of data transformation libraries built for performance and developer experience. Each package in the Molt ecosystem is designed to handle a specific data format with extreme efficiency and type safety.

Available Packages โ€‹

  • @sylphx/molt-json - Type-preserving JSON parser and serializer
  • @sylphx/molt-yaml - Ultra-fast YAML processor
  • @sylphx/molt-toml - High-performance TOML parser
  • @sylphx/molt-ini - Fast INI configuration parser
  • @sylphx/molt-csv - Blazingly fast CSV handler
  • @sylphx/molt-xml - Competitive XML parser with dirty input support
  • @sylphx/molt-msgpack - Binary MessagePack encoder/decoder
  • @sylphx/molt-toon - LLM-optimized Token-Oriented Object Notation

Why Choose Molt? โ€‹

๐Ÿš€ Exceptional Performance โ€‹

Molt consistently outperforms industry-standard libraries across all formats:

FormatPerformancevs Competition
YAML1,021,050 ops/s2.87x faster than js-yaml
TOML892,620 ops/s2.07x faster than @iarna/toml
JSON610,000 ops/s1.7x faster serialization
INIHigh2-3x faster than ini (npm)
CSV775,770 ops/s5.9x faster than papaparse
XML102,975 ops/sMatches fast-xml-parser
MessagePackCompetitiveComparable to @msgpack/msgpack
TOONN/A30-60% fewer tokens for LLMs

See Benchmarks for detailed comparisons.

๐Ÿ›ก๏ธ Type Safety โ€‹

JavaScript types like Date, BigInt, Map, Set, and RegExp are automatically preserved through serialization with molt-json:

typescript
const data = {
  created: new Date(),
  id: 123456789012345678901n,
  tags: new Set(['a', 'b', 'c']),
  config: new Map([['key', 'value']])
}

const json = molt.stringify(data)
const restored = molt(json)

restored.created instanceof Date  // true
restored.id === 123456789012345678901n  // true
restored.tags instanceof Set  // true

๐Ÿงน Dirty Input Support โ€‹

Real-world data is messy. Molt handles it gracefully:

typescript
// JavaScript-style comments
const data = molt(`{
  // This is a comment
  name: 'Alice',         // Unquoted key
  email: 'alice@test.com', // Single quotes
  tags: [1, 2, 3,],      // Trailing comma
}`)

๐Ÿ“ฆ Zero Dependencies โ€‹

All Molt packages are production-grade with zero external dependencies. Pure TypeScript with optional Rust/WASM acceleration for compute-intensive operations.

โšก Ready for Production โ€‹

  • 120+ test cases per package
  • Streaming support for large files
  • Schema validation (Zod, JSON Schema compatible)
  • Comprehensive error messages
  • Type-safe TypeScript APIs

Quick Installation โ€‹

Using npm โ€‹

bash
npm install @sylphx/molt-json

Using pnpm โ€‹

bash
pnpm add @sylphx/molt-json

Using Bun โ€‹

bash
bun add @sylphx/molt-json

Replace molt-json with your desired package: molt-yaml, molt-toml, molt-csv, or molt-xml.

Basic Usage Examples โ€‹

JSON โ€‹

typescript
import { molt, stringify } from '@sylphx/molt-json'

// Parse dirty JSON
const data = molt('{ name: "Alice", age: 30 }')

// Stringify with type preservation
const json = stringify({ created: new Date() })

YAML โ€‹

typescript
import { parse, stringify } from '@sylphx/molt-yaml'

const config = parse(`
  database:
    host: localhost
    port: 5432
`)

console.log(stringify(config))

TOML โ€‹

typescript
import { parse, stringify } from '@sylphx/molt-toml'

const config = parse(`
[package]
name = "my-app"
version = "1.0.0"
`)

CSV โ€‹

typescript
import { parse, stringify } from '@sylphx/molt-csv'

const records = parse('name,age\nAlice,30')
console.log(stringify(records))

XML โ€‹

typescript
import { parse, toObject } from '@sylphx/molt-xml'

const doc = parse('<root><item>value</item></root>')
const obj = toObject(doc)

INI โ€‹

typescript
import { molt } from '@sylphx/molt-ini'

const config = molt(`
[database]
host = localhost
port = 5432
`)

MessagePack โ€‹

typescript
import { encode, decode } from '@sylphx/molt-msgpack'

const binary = encode({ user: 'alice' })
const data = decode(binary)

TOON โ€‹

typescript
import { parseTOON, serializeTOON } from '@sylphx/molt-toon'

// Parse TOON format
const data = parseTOON(`
users:
  id | name  | age
  1  | Alice | 30
  2  | Bob   | 25
`)

// Serialize to TOON (30-60% fewer tokens)
const toon = serializeTOON(data)

Next Steps โ€‹

Need Help? โ€‹

FAQ โ€‹

Q: Which package should I choose? โ€‹

A: Choose based on your data format:

  • JSON data โ†’ molt-json
  • YAML config โ†’ molt-yaml
  • TOML settings โ†’ molt-toml
  • CSV data โ†’ molt-csv
  • XML documents โ†’ molt-xml

Q: Does Molt require special setup? โ€‹

A: No! Just install the package and start using it. Zero configuration needed.

Q: Are types truly preserved in molt-json? โ€‹

A: Yes! Date, BigInt, Map, Set, RegExp, Uint8Array, and more are automatically preserved through stringify/parse cycles.

Q: How much faster is Molt really? โ€‹

A: Significantly faster in most cases. YAML is 2-415x faster, TOML is 2-9x faster, JSON serialization is 1.7-2.3x faster. See benchmarks for details.

Q: Is this production-ready? โ€‹

A: Absolutely. Molt is used in production applications with 120+ tests per package and zero external dependencies.


Ready to get started? Check out the Installation Guide next!

Released under the MIT License.