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

circuit-to-svg

v0.0.345

Published

Convert Circuit JSON to SVG

Downloads

68,942

Readme

circuit-to-svg

A TypeScript library for converting Circuit JSON to Schematic, PCB and Assembly SVG representations.

Getting Started Contributor Video

npm add circuit-to-svg
# or...
bun add circuit-to-svg

Overview

This library provides functionality to convert Circuit JSON into SVG (Scalable Vector Graphics) representations. It supports both schematic and PCB (Printed Circuit Board), and Assembly layouts.

Installation

npm install circuit-to-svg

Usage

import { readFileSync, writeFileSync } from 'fs'
import { convertCircuitJsonToSchematicSvg } from 'circuit-to-svg'

const circuitJson = JSON.parse(readFileSync('circuit.json', 'utf8'))
const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson)

writeFileSync('schematic.svg', schematicSvg)

Explore the API sections below to render PCB, assembly, pinout, simulation, and solder paste views.

| Function | Description | | --- | --- | | convertCircuitJsonToSchematicSvg | Generate schematic SVG output from Circuit JSON. | | convertCircuitJsonToSchematicSimulationSvg | Overlay simulation data on schematic diagrams. | | convertCircuitJsonToPcbSvg | Render PCB layouts as SVG graphics. | | convertCircuitJsonToSolderPasteMask | Create solder paste mask layers for fabrication. | | convertCircuitJsonToAssemblySvg | Produce assembly view SVGs for board visualization. | | convertCircuitJsonToPinoutSvg | Build annotated pinout diagrams for boards and modules. | | convertCircuitJsonToSimulationGraphSvg | Plot simulation experiment results as SVG graphs. |

API

convertCircuitJsonToSchematicSvg

convertCircuitJsonToSchematicSvg(circuitJson: AnyCircuitElement[], options?): string

Converts a schematic circuit description to an SVG string.

import { convertCircuitJsonToSchematicSvg } from 'circuit-to-svg'

const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson, {
  includeVersion: true,
})

Schematic grid snapshot

Options

  • width and height – dimensions of the output SVG. Defaults to 1200x600.
  • grid – enable a schematic grid (true) or configure cell size and labels.
  • labeledPoints – annotate specific coordinates with helper labels.
  • colorOverrides – override portions of the schematic color palette.
  • includeVersion – if true, add a data-circuit-to-svg-version attribute to the root <svg>.

convertCircuitJsonToPcbSvg

convertCircuitJsonToPcbSvg(circuitJson: AnyCircuitElement[], options?): string

Converts a PCB layout description to an SVG string.

import { convertCircuitJsonToPcbSvg } from 'circuit-to-svg'

const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson, {
  matchBoardAspectRatio: true,
  backgroundColor: '#1e1e1e',
})

PCB default snapshot

Options

  • width and height – dimensions of the output SVG. Defaults to 800x600.
  • matchBoardAspectRatio – if true, adjust the SVG dimensions so the resulting aspect ratio matches the pcb_board found in the circuit JSON.
  • backgroundColor – fill color for the SVG background rectangle. Defaults to "#000".
  • drawPaddingOutsideBoard – if false, omit the board outline and extra padding around it. Defaults to true.
  • showPcbNotes – if false, hide all pcb_note* overlay primitives at render time. Defaults to true.
  • shouldDrawErrors – if true, display visual error indicators (red diamonds with text) for error elements in the circuit JSON. Supports:
    • pcb_trace_error – errors related to PCB traces
    • pcb_footprint_overlap_error – errors for overlapping pads, plated holes, and holes (displays error indicators at each affected element with connecting lines)
    Defaults to false.
  • includeVersion – if true, add a data-circuit-to-svg-version attribute to the root <svg>.

convertCircuitJsonToAssemblySvg

Converts circuit JSON into an assembly view of the board and components.

import { convertCircuitJsonToAssemblySvg } from 'circuit-to-svg'

const assemblySvg = convertCircuitJsonToAssemblySvg(circuitJson, {
  includeVersion: false,
})

Assembly board snapshot

Options

  • width and height – dimensions of the output SVG. Defaults to 800x600.
  • includeVersion – if true, add a data-circuit-to-svg-version attribute to the root <svg>.

convertCircuitJsonToPinoutSvg

Generates pinout diagrams that call out ports, pads, and holes for boards or modules.

import { convertCircuitJsonToPinoutSvg } from 'circuit-to-svg'

const pinoutSvg = convertCircuitJsonToPinoutSvg(circuitJson)

Pinout snapshot

Options

  • width and height – dimensions of the output SVG. Defaults to 800x600.
  • includeVersion – if true, add a data-circuit-to-svg-version attribute to the root <svg>.

convertCircuitJsonToSchematicSimulationSvg

Overlays simulation results directly on the rendered schematic for easy debugging.

import { convertCircuitJsonToSchematicSimulationSvg } from 'circuit-to-svg'

const schematicSimulationSvg = convertCircuitJsonToSchematicSimulationSvg({
  circuitJson,
  simulation_experiment_id: 'simulation-experiment-id',
  simulation_transient_voltage_graph_ids: ['transient-graph-id'],
  schematicHeightRatio: 0.6,
})

Schematic simulation snapshot

Options

  • width and height – overall SVG dimensions. Defaults to 1200x1200.
  • schematicHeightRatio – ratio of the SVG dedicated to the schematic view. Defaults to 0.55.
  • schematicOptions – forward additional schematic rendering options (except width, height, and includeVersion).
  • includeVersion – if true, add a data-circuit-to-svg-version attribute to the root <svg>.
  • graphAboveSchematic – if true, place the simulation graph above the schematic instead of below (defaults to false).

convertCircuitJsonToSimulationGraphSvg

Creates standalone graphs for circuit simulation experiments.

import { convertCircuitJsonToSimulationGraphSvg } from 'circuit-to-svg'

const simulationGraphSvg = convertCircuitJsonToSimulationGraphSvg({
  circuitJson,
  simulation_experiment_id: 'simulation-experiment-id',
  simulation_transient_voltage_graph_ids: ['transient-graph-id'],
})

Simulation graph snapshot

Options

  • width and height – SVG dimensions for the graph. Defaults to 1200x600.
  • includeVersion – if true, add a data-circuit-to-svg-version attribute to the root <svg>.

convertCircuitJsonToSolderPasteMask

convertCircuitJsonToSolderPasteMask(circuitJson: AnyCircuitElement[], options: { layer: 'top' | 'bottom'; width?; height?; includeVersion? }): string

Produces top and bottom solder paste mask renderings suitable for stencil generation.

import { convertCircuitJsonToSolderPasteMask } from 'circuit-to-svg'

const solderPasteMaskSvg = convertCircuitJsonToSolderPasteMask(circuitJson, {
  layer: 'top',
})

Solder paste snapshot

Options

  • layer'top' | 'bottom', chooses which solder paste layer to render. Defaults to 'top'.
  • width and height – dimensions of the output SVG. Defaults to 800x600.
  • includeVersion – if true, add a data-circuit-to-svg-version attribute to the root <svg>.