Skip to content

Repository files navigation

Oxidised Vector Graphics (OXVG)

release npm crate discord wiki

OXVG is the fastest1 SVG toolchain for optimisation, linting, transformation, and manipulation. Usable via CLI and libraries for Node, WASM, or Rust.

Installation

Install OXVG using the package manger of your choice.

Cargo

cargo install oxvg

Homebrew

brew install oxvg

View commands

oxvg --help

Optimise an SVG

oxvg optimise < input.svg > output.svg

🎯 Tools

The following tools are available in a CLI binary.

🪶 Optimiser

Tip

You can try out the OXVG optimiser right in your browser using OXVGUI, a simple web-based playground built by Jonas Geiler (@jonasgeiler).

An SVG optimiser similar to SVGO is available. It can run up to 50x faster, especially on larger file-sets.

We based the optimiser on SVGO and aim for compatibility with it, but it isn't a 1-for-1 replacement. As a result, some plugins may behave differently.

See the SVGO parity guide to understand the differences and instructions for how to migrate your existing configuration.

# or `oxvg optimize`
cat my-file.svg | oxvg optimise > my-file.optimised.svg
Screencast.From.2026-08-09.14-54-58.mp4

🤖 Actions (Under Development2)

Actions are a set of commands invoked by a program in order to manipulate an SVG document or pull information from it. It is comparable to Inkscape's actions, but without any dependency on the UI or rendering.

cat overlapping-paths.svg | oxvg action -- -select path -path-intersect > merged-paths.svg

🧹 Linter

OXVG includes a basic linter similar to svglint or vnu to make catching issues in SVG documents much easier. The linter can report SVG issues directly from the command line or through its language-server integration.

# Start language-server
oxvg lint serve
# Report diagnostics to stderr
oxvg lint check w3c/ -r
linting output

⚛️ JSX

A JSX transformer to take SVG documents and transform them into JSX components, for use in React, Preact, Native, or any other JSX-compatible language.

This aims to implement SVGR as closely as possible.

cat my-file.svg | oxvg jsx --template template.jsx | prettier > my-file.svg.jsx

📖 Libraries

If you're a Rust developer wanting to work with SVGs in your project, we have a set of crates at your disposal.

OXVG splits functionality into separate crates that you can use independently according to your project's needs. It offers libraries for DOM parsing and traversal, path handling, optimisation, and manipulation.

Actions (Unstable3)

Actions are programmatic commands for manipulating and inspecting SVG documents.

This crate provides a set of types that you can use to implement a DOM similar to that of the browser web standards. Though it's not a 1-to-1 match; it's designed for easily traversing and manipulating the DOM.

There's currently an implementation suitable for use with either the xml5ever or the roxmltree parser which can do the following.

  • Parse and serialise XML, SVG, and HTML documents
  • Commonly used browser API implementations for DOM nodes, elements, attributes, etc.
  • An implementation of selectors for using DOM CSS queries

This crate provides types for SVG content.

  • Parsing attributes into structured data
  • Enumerators for known elements, attributes, and namespaces

This is where you'll find the jobs (i.e. SVGO plugins) for our optimiser, which you can also use as a library in your applications.

Path (Unstable3)

This is a library for parsing, optimising, and serialising path definitions (e.g. <path d="..." />).

Please expect some instability as we may add new features to enable simple manipulations for paths in the future.

This is a library for parsing SVG, optimising, and transforming it into JSX modules.

Building

You can build the project for yourself by doing the following

git clone git@github.com:noahbald/oxvg.git
cd oxvg
cargo build --profile release --package oxvg --bin oxvg
# UNIX
./target/release/oxvg --help
# Windows
.\target\release\oxvg.exe --help

Or you can install it through cargo

cargo install oxvg
oxvg --help

Contributing

You're welcome to help out and pick up a good first issue or email me to help.

Contributing and architecture guides are available as well.


Inspiration and Thanks

Thank you to these high quality, open source projects on SVG tooling

  • SVGO
  • SVGR
  • Inkscape
  • Linebender

Thank you to these projects for helping make OXVG more popular

Licensing

OXVG is open-source and licensed under the MIT License

This project ports or copies code from other open-source (MIT) projects, listed below

  • SVGO
  • SVGR
  • OXC
  • Parcel
  • Kurbo

Footnotes

  1. Fastest I'm aware of; see benchmarks

  2. CLI commands under development are safe to use but are either incomplete or likely to experience breaking changes in future.

  3. Unstable libraries are either incomplete or likely to experience breaking changes in future. 2

About

Fastest SVG toolchain for optimisation, minification, linting, and actions. Usable via CLI, Node, Wasm, or Rust.

Topics

Resources

Stars

596 stars

Watchers

6 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages