Skip to content

SylphxAI/synth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Synth

The World's Fastest AST Processor - 50-3000x faster than unified

npm License: MIT

Features

  • 50-3000x faster than unified/remark
  • 🌍 Universal AST - Same interface for 19+ languages
  • 🔄 Incremental parsing - <1ms response time, 99%+ token reuse
  • 📦 Zero dependencies - Minimal bundle size
  • 🛠️ Rich tooling - Formatters, minifiers, linters, metrics

Quick Start

npm install @sylphx/synth @sylphx/synth-md
import { parse, traverse, getNode } from '@sylphx/synth-md'

// Parse markdown (42x faster than remark!)
const tree = parse('# Hello **World**')

// Traverse the AST
traverse(tree, {
  heading: (ctx) => console.log('Heading level:', ctx.node.data?.depth),
  strong: (ctx) => console.log('Found bold text')
})

// Get source text from any node
const heading = tree.nodes[1]
const source = tree.meta.source.slice(
  heading.span.start.offset,
  heading.span.end.offset
)

Node Structure

All languages share the same BaseNode interface:

interface BaseNode {
  id: number                      // Unique ID
  type: string                    // 'heading', 'paragraph', etc.
  span?: {                        // Source location
    start: { line, column, offset }
    end: { line, column, offset }
  }
  parent: number | null           // Parent node ID
  children: number[]              // Child node IDs
  data?: Record<string, unknown>  // Language-specific data
}

Supported Languages

Category Languages
Markup Markdown, HTML, CSS, JSX, Vue
Programming JavaScript/TypeScript, Python, Go, Rust, Java, PHP, Ruby, C
Data JSON, YAML, TOML, INI, XML
Query SQL, GraphQL, Protocol Buffers

Performance

Operation Synth unified Speedup
Parse 1KB 0.001 ms 0.10 ms 92x
Parse 3KB 0.005 ms 0.58 ms 520x
Parse 10KB 0.03 ms 3.50 ms 3154x

Documentation

📚 Full Documentation (coming soon)

Packages

Core

  • @sylphx/synth - Core types, traversal, query index

Parsers

  • @sylphx/synth-md - Markdown (CommonMark + GFM)
  • @sylphx/synth-js - JavaScript/TypeScript
  • @sylphx/synth-html - HTML5
  • @sylphx/synth-json - JSON
  • @sylphx/synth-yaml - YAML
  • @sylphx/synth-css - CSS3
  • View all packages...

Tools

  • @sylphx/synth-js-format - JavaScript formatter
  • @sylphx/synth-js-minify - JavaScript minifier
  • @sylphx/synth-lint - Universal linter
  • @sylphx/synth-metrics - Code metrics

Development

# Install dependencies
bun install

# Build all packages
bun run build

# Run tests
bun run test

# Run docs locally
bun run docs:dev

License

MIT


Powered by Sylphx · Built with biome-config · tsconfig · doctor · bump

About

🎹 Synth - synthesis and generation tools

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •