Skip to content
Caffeine, drawn by RDKit's mol_to_svgCaffeine, drawn by RDKit's mol_to_svg

pglite-rdkit

RDKit Postgres Cartridge, running in your browser. Store, search and draw molecules with SQL, no PostgreSQL server needed.

The full RDKit cartridge

The mol, qmol, bfp and sfp types, descriptors, fingerprints, InChI and SVG drawing. It’s the same cartridge used with server Postgres, compiled to WebAssembly.

Indexed search

GiST indexes speed up substructure (@>), similarity (%) and nearest-neighbour (<%>) queries, just as they do on a server.

Runs wherever PGlite runs

Browsers, Node, Bun and Deno. One extensions: { rdkit } option and a 2 MB bundle, loaded on demand.

Try before you install

The Playground and REPL on this site run the real extension in your browser. Nothing is sent to a server.

npm install @electric-sql/pglite pglite-rdkit
import { PGlite } from '@electric-sql/pglite'
import { rdkit } from 'pglite-rdkit'
const pg = await PGlite.create({ extensions: { rdkit } })
await pg.exec('CREATE EXTENSION rdkit')
const { rows } = await pg.query(`SELECT mol_to_smiles('C1=CC=CC=C1O'::mol) AS smiles`)
// [{ smiles: 'Oc1ccccc1' }]

In Vite, exclude both packages from optimizeDeps, because they find their WebAssembly files through import.meta.url.

Invalid SMILES raises a normal Postgres error, and the database stays usable. The RDKit cartridge documentation lists every function. Two features aren’t in the WebAssembly build: Avalon fingerprints, and FreeType text (labels in SVG are drawn as paths). There’s more in the README.

The query below finds every molecule in a sample table that contains a carboxylic acid and draws it. Edit the query and press ⌘/Ctrl + Enter to run it again. For more examples, open the Playground. To build your own tables, use the REPL.