npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

kicad-sch-ts

v1.0.3

Published

TypeScript library for KiCad schematic files

Readme

kicad-sch-ts

A TypeScript library for programmatically reading, writing, and manipulating KiCAD 7/8 schematic files.

Features

  • Round-trip fidelity: Load and save schematic files without losing any data
  • Full type safety: Complete TypeScript definitions for all KiCAD schematic elements
  • Rich CLI: Command-line tools for common operations
  • MCP Server: AI assistant integration via Model Context Protocol
  • Comprehensive API: Work with components, wires, labels, sheets, and more

Installation

npm install kicad-sch-ts

Quick Start

import { Schematic } from 'kicad-sch-ts';

// Load an existing schematic
const sch = Schematic.load('my_project.kicad_sch');

// Access components
for (const component of sch.components) {
  console.log(`${component.reference}: ${component.value}`);
}

// Access wires
console.log(`Wires: ${sch.wires.length}`);

// Save (preserves round-trip fidelity)
sch.save('my_project.kicad_sch');

CLI Usage

# Create a demo schematic
kicad-sch demo -o demo.kicad_sch

# Run Electrical Rules Check
kicad-sch erc my_project.kicad_sch

# Audit BOM properties
kicad-sch bom my_project.kicad_sch -p PartNumber,Manufacturer

# Generate BOM CSV
kicad-sch bom-manage my_project.kicad_sch -o bom.csv

# Search for symbols
kicad-sch find-libraries -s resistor

# Extract netlist
kicad-sch netlist my_project.kicad_sch

# Convert to Python code
kicad-sch kicad-to-python my_project.kicad_sch -o generate.py

# Export documentation
kicad-sch export-docs my_project.kicad_sch -f markdown

# Start MCP server for AI assistants
kicad-sch mcp

API Reference

Schematic Class

// Load a schematic
const sch = Schematic.load('path/to/schematic.kicad_sch');

// Create a new schematic
const sch = Schematic.create('My Schematic');

// Parse from string
const sch = Schematic.fromString(content);

// Save
sch.save('output.kicad_sch');

// Format to string
const content = sch.format();

Component Collection

// Add a component
sch.components.add({
  libId: 'Device:R',
  reference: 'R1',
  value: '10k',
  position: { x: 100.33, y: 101.6 },
});

// Get by reference
const comp = sch.components.get('R1');

// Iterate
for (const comp of sch.components) {
  console.log(comp.reference, comp.value);
}

// Modify
const r1 = sch.components.get('R1');
r1.value = '20k';
r1.setProperty('Manufacturer', 'Yageo');

// Remove
sch.components.remove('R1');

Wire Collection

// Add a wire
sch.wires.add({
  start: { x: 100.33, y: 101.6 },
  end: { x: 106.68, y: 101.6 },
});

// Find wires at a point
const wires = sch.wires.findAtPoint({ x: 100.33, y: 101.6 });

Label Collection

// Add labels
sch.labels.add({ text: 'VCC', position: { x: 50, y: 50 } });
sch.labels.addGlobal({ text: 'GND', position: { x: 60, y: 60 } });
sch.labels.addHierarchical({
  text: 'DATA',
  position: { x: 70, y: 70 },
  shape: 'bidirectional',
});

Analysis Tools

import {
  ConnectivityAnalyzer,
  ElectricalRulesChecker,
  BOMPropertyAuditor,
  HierarchyManager,
} from 'kicad-sch-ts';

// Connectivity analysis
const analyzer = new ConnectivityAnalyzer(sch);
const nets = analyzer.analyzeNets();
const unconnected = analyzer.findUnconnectedPins();

// ERC
const checker = new ElectricalRulesChecker(sch);
const result = checker.check();
console.log(`Passed: ${result.passed}, Errors: ${result.errorCount}`);

// BOM auditing
const auditor = new BOMPropertyAuditor();
const issues = auditor.auditSchematic(path, ['PartNumber', 'Manufacturer']);

// Hierarchy management
const hierarchy = new HierarchyManager(sch);
const tree = hierarchy.buildHierarchyTree(true);
const allComponents = hierarchy.getAllComponents();

Symbol Library

import { getSymbolCache } from 'kicad-sch-ts';

const cache = getSymbolCache();

// Search for symbols
const results = cache.searchSymbols('resistor', 20);

// Get specific symbol
const symbol = cache.getSymbol('Device:R');

MCP Server

For AI assistant integration, start the MCP server:

kicad-sch mcp

The server provides tools for:

  • manage_schematic: Create, load, save schematics
  • manage_component: Add, modify, remove components
  • manage_wire: Add, remove wires
  • manage_label: Add, remove labels
  • analyze_connectivity: Analyze nets and connections
  • analyze_hierarchy: Analyze hierarchical structure
  • run_erc: Run electrical rules check
  • search_symbols: Search symbol libraries
  • get_symbol_info: Get detailed symbol information
  • discover_pins: Find pins at positions

TypeScript Advantages

  • Static typing: Rich editor hints and compile-time checks for schematic data.
  • Speed: Faster analysis and tool execution in Node.js workflows.
  • Ergonomics: Convenient helpers for hierarchy, search, and parity-focused APIs.

Python → TypeScript Migration

  • Schematic.load(...) / Schematic.create(...) are direct equivalents.
  • Collections map 1:1 (components, wires, labels, sheets).
  • Analysis classes carry the same semantics (ConnectivityAnalyzer, ElectricalRulesChecker, HierarchyManager).
  • For scripting, use Node.js tooling instead of Python entry points.

Recipes

BOM Audit

import { BOMPropertyAuditor } from "kicad-sch-ts";

const auditor = new BOMPropertyAuditor();
const report = auditor.auditSchematic("my_project.kicad_sch", [
  "PartNumber",
  "Manufacturer",
]);
console.log(report);

ERC

import { ElectricalRulesChecker, Schematic } from "kicad-sch-ts";

const sch = Schematic.load("my_project.kicad_sch");
const checker = new ElectricalRulesChecker(sch);
const result = checker.check();
console.log(result);

Connectivity

import { ConnectivityAnalyzer, Schematic } from "kicad-sch-ts";

const sch = Schematic.load("my_project.kicad_sch");
const analyzer = new ConnectivityAnalyzer(sch);
const nets = analyzer.analyzeNets();
console.log(nets.map((net) => net.name));

Testing

npm test

npm test runs a pretest step that rebuilds better-sqlite3. If it fails, install native build tools (e.g. xcode-select --install on macOS) and retry.

Compatibility

  • Node.js: 18.0.0 or later
  • KiCAD: 7.x, 8.x schematic format

Parity + Limitations

Parity status and limitation decisions are tracked in PARITY.md, including a module-by-module matrix and rationale for match/improve/defer calls.

Recent parity improvements include multi-unit helpers, intersection-aware connectivity, symbol-geometry property positioning, and lightweight logging utilities.

Known Limitations

  • See PARITY.md for any currently tracked limitations or deferred items.

License

MIT