Beginner · 5–15 min

Tutorials

Learn chematic by building small, useful chemistry tools. Each tutorial has a clear starting point, runnable code, and a next step.

Choose a starting point

Browser

Analyze your first molecule

Parse a SMILES string and inspect its 2D structure and basic properties without a backend.

What you will makeA local molecule analysis pageNext stepTry the browser demo
Steps
  1. Open the browser demo.
  2. Enter CCO, the SMILES for ethanol, then run the analysis.
  3. Compare the structure drawing with the molecular formula and molecular weight.

CheckYou should see a 2D structure and descriptor values for ethanol.

If it does not workIf the structure is blank, check that the input is valid SMILES and try CCO again.

Python

Use chematic from Python

Install the package, parse a molecule, and use the same core in a notebook.

What you will makeA first notebook cellNext stepRead the Python guide
Steps
  1. Create a virtual environment and install chematic.
  2. Import the package and parse CCO.
  3. Print the molecule or one descriptor to confirm the call completed.

CheckThe notebook returns a molecule object without sending the structure to a server.

If it does not workActivate the environment before installing, and check the package name if the import is not found.

mol = chematic.from_smiles("CCO")
Open guide

Python

Find similar molecules

Create fingerprints and compare molecules with Tanimoto similarity.

What you will makeA small similarity searchNext stepRead the API cookbook
Steps
  1. Parse a query molecule and two candidates.
  2. Generate the same fingerprint type for each molecule.
  3. Calculate Tanimoto similarity and sort the candidates.

CheckThe identical molecule scores 1.0; less similar structures score lower.

If it does not workUse the same fingerprint settings for every molecule before comparing scores.

mol.ecfp4()
Open guide

Python

Process a structure file

Move from one molecule to a CSV or SDF batch workflow with local, repeatable output.

What you will makeA batch analysis scriptNext stepRead the batch guide
Steps
  1. Prepare a file with one SMILES value per row.
  2. Parse each row and calculate the selected properties.
  3. Write results together with the original input and any parse error.

CheckThe output has one traceable result per input row, including invalid rows.

If it does not workDo not discard the original string; it makes failed rows easy to inspect and retry.

for smiles in rows:
Open guide

Rust

Build a native Rust tool

Add chematic to a Rust project and keep parsing and chemistry logic in one process.

What you will makeA Rust CLI or service foundationNext stepRead the Rust guide
Steps
  1. Create a small binary crate and add the required features.
  2. Parse one known SMILES in main.
  3. Return a clear error for invalid input before adding batch behavior.

CheckThe binary builds locally and produces a deterministic result for the same input.

If it does not workStart with only the features you need if compile time or binary size matters.

cargo add chematic --features "smiles,perception,chem,3d,fp"
Open guide

AI agents

Connect an AI agent

Start with a local stdio MCP server and use self-hosted HTTP only when the client cannot launch a process.

What you will makeA local chemistry tool connectionNext stepRead the MCP guide
Steps
  1. Install the versioned MCP package locally.
  2. Register the stdio command in your AI client.
  3. Ask the client to parse a test SMILES and inspect the returned structured data.

CheckThe client can call a chemistry tool and receive a structured response without a hosted service.

If it does not workUse the loopback HTTP adapter only when the client cannot start a local process.

chematic-mcp
Open guide

Browser

Convert SMILES to a 2D SVG structure

Turn a SMILES string into a scalable structure drawing that you can inspect locally in the browser.

What you will makeAn SVG molecular depictionNext stepOpen the step-by-step tutorial
Steps
  1. Open the browser guide or Playground.
  2. Paste the aspirin SMILES shown here.
  3. Run depiction and inspect the generated SVG structure.

CheckYou should see a 2D aspirin structure that remains crisp when enlarged.

If it does not workUse a valid, complete SMILES string; SVG depiction does not require a backend.

CC(=O)OC1=CC=CC=C1C(=O)O
Open guide

Python

Calculate molecular weight, LogP, and TPSA from SMILES

Parse one molecule and calculate common physicochemical descriptors for an early screening workflow.

What you will makeA compact property reportNext stepOpen the step-by-step tutorial
Steps
  1. Parse a known SMILES into a molecule object.
  2. Calculate molecular weight, LogP, and TPSA from that same object.
  3. Keep the input SMILES next to the calculated values in your output.

CheckThe three values are returned locally for the same parsed molecule.

If it does not workTreat descriptor values as calculated properties, not experimental measurements or clinical predictions.

mol = chematic.from_smiles("CCO")
mol.mw
mol.logp
mol.tpsa
Open guide

Browser

Search a molecule with a SMARTS pattern

Check whether a molecule contains a functional-group pattern, then inspect the highlighted atoms.

What you will makeA local substructure matchNext stepOpen the step-by-step tutorial
Steps
  1. Open the homepage feature examples.
  2. Keep aspirin as the molecule and enter C(=O)O as the SMARTS pattern.
  3. Run the search and inspect the highlighted match in the SVG.

CheckThe result reports a match and highlights the matching atoms.

If it does not workSMARTS describes a pattern, not necessarily a complete molecule; start with a small pattern.

Browser

Analyze an SDF or CSV file locally

Load a structure file, inspect its rows, and keep filtering or exporting in the browser.

What you will makeA local structure-file workflowNext stepOpen the step-by-step tutorial
Steps
  1. Open Local Compound Explorer.
  2. Load an SDF, CSV, or .smi file from your computer.
  3. Filter or sort the local results, then export the result you need.

CheckThe file is handled in the browser without a dedicated analysis backend.

If it does not workKeep a source copy of the file and use a small sample first to confirm the expected SMILES column or SDF fields.

compounds.sdf
Open guide

Browser

Validate a SMILES input before analysis

Give an invalid molecular string a clear error before you depict a structure or calculate properties.

What you will makeA local input-validation checkNext stepOpen the step-by-step tutorial
Steps
  1. Analyze CCO as a valid reference input.
  2. Replace it with incomplete C1CC.
  3. Confirm that the page shows an error rather than a made-up result.

CheckValid input produces a structure; incomplete syntax produces a visible error.

If it does not workA parse error is about syntax, not a chemical safety or experimental-validity decision.

Valid: CCO
Invalid: C1CC
Open guide

Browser

Compare two molecules with ECFP4 similarity

Compare two local structures and keep the inputs beside a reproducible Tanimoto score.

What you will makeA local similarity comparisonNext stepOpen the step-by-step tutorial
Steps
  1. Open the interactive feature examples.
  2. Compare aspirin with salicylic acid using ECFP4.
  3. Record both inputs, settings, and the displayed score.

CheckThe same input pair and fingerprint setting returns the same local score.

If it does not workA similarity score does not establish activity, safety, or synthetic feasibility.

Aspirin
Salicylic acid
ECFP4
Open guide

Browser

Check basic drug-likeness indicators

Inspect calculated descriptors and the displayed Lipinski result for one parsed molecule.

What you will makeA first-pass property checkNext stepOpen the step-by-step tutorial
Steps
  1. Analyze one complete SMILES in the browser.
  2. Read molecular weight, LogP, TPSA, HBD, HBA, and Lipinski.
  3. Keep the exact input beside the calculated values.

CheckThe result panel presents the property indicators for the parsed molecule.

If it does not workThese are calculated indicators, not a conclusion about efficacy, safety, or clinical suitability.

CC(=O)OC1=CC=CC=C1C(=O)O
Open guide

Python

Create a descriptor CSV without losing invalid rows

Keep source-row identity and parser errors while calculating a compact property report.

What you will makeA traceable descriptor CSVNext stepOpen the step-by-step tutorial
Steps
  1. Read a CSV with a smiles column.
  2. Record values or a ValueError for each row.
  3. Write one report before filtering valid rows.

CheckEach non-empty input row has an explicit status.

If it does not workbulk.descriptors skips invalid SMILES, so validate before using it for a source-table report.

chematic.from_smiles(smiles)
Open guide

Python

Rank a SMILES library by ECFP4 similarity

Run a one-to-many local Tanimoto search after validating the candidate library.

What you will makeA reproducible top-hit listNext stepOpen the step-by-step tutorial
Steps
  1. Validate candidate SMILES.
  2. Score one query against the local list.
  3. Retain inputs, method, and ranked scores.

CheckThe same valid inputs return the same ranking.

If it does not workInvalid entries are skipped by the bulk API and can break raw-row alignment.

bulk.tanimoto_search(query, library)
Open guide

Python

Filter a SMILES library with SMARTS

Screen a local list for a functional-group pattern and retain hits in input order.

What you will makeA local substructure hit listNext stepOpen the step-by-step tutorial
Steps
  1. Choose a SMARTS pattern.
  2. Screen the local list in parallel.
  3. Save the pattern and matching SMILES together.

CheckMatching strings remain in source order.

If it does not workThis API treats invalid SMILES as non-matches, so validate data when a negative needs an explanation.

bulk.substructure_search(pattern, smiles)
Open guide

Rust

Build a Rust SMILES CLI with local descriptors

Create a native CLI that parses CCO and reports atom count, molecular weight, and TPSA.

What you will makeA local Rust chemistry CLINext stepOpen the step-by-step tutorial
Steps
  1. Create a binary crate.
  2. Enable the three required features.
  3. Parse CCO and print its basic descriptors.

CheckCCO reports atoms=3, mw=46.07, and tpsa=20.23.

If it does not workUse the smallest documented feature set for the workflow you actually need.

cargo add chematic --features "smiles,perception,chem"
Open guide

AI agents

Verify a local MCP SMILES tool over stdio

Send a JSON-RPC parse request to the local MCP server before registering it in a client.

What you will makeA proven local stdio responseNext stepOpen the step-by-step tutorial
Steps
  1. Clone the source repository.
  2. Send a local JSON-RPC request over stdio.
  3. Confirm the structured benzene response.

CheckThe result has valid=true, atoms=6, bonds=6, and mol_weight=78.114.

If it does not workThis is a local stdio process, not a hosted MCP URL.

tools/call: parse_smiles
Open guide

Python

Get a molecular formula and molecular weight from SMILES

Parse one SMILES and keep two basic calculated values beside the original input.

What you will makeA compact, traceable molecule recordNext stepOpen the step-by-step tutorial
Steps
  1. Parse one complete SMILES such as CCO.
  2. Print the formula and molecular weight.
  3. Keep the input and package version with the output.

CheckCCO returns C2H6O and a molecular weight of about 46.07 g/mol.

If it does not workA formula does not uniquely identify a structure, and molecular weight here is a calculation rather than an experimental measurement.

mol = chematic.from_smiles("CCO")
mol.formula
mol.mw
Open guide

Browser

Add a browser molecule check with a pinned CDN module

Load the published WebAssembly package without a bundler, then calculate aspirin molecular weight in a browser.

What you will makeA release-pinned local browser checkNext stepOpen the step-by-step tutorial
Steps
  1. Serve a small HTML page from HTTPS or a local server.
  2. Paste the version-pinned module script.
  3. Confirm 180.16 in the browser console, then release the molecule object.

CheckAspirin prints 180.16 after the pinned module initializes.

If it does not workDo not use @latest, and do not rely on a file URL for ES-module loading.

import init, { parse_smiles } from ".../chematic_wasm.js"
await init()
Open guide

AI agents

Resolve a compound name to SMILES with local MCP

Look up aspirin through PubChem from a local MCP process, then retain the returned SMILES and its source.

What you will makeA documented name-to-SMILES lookupNext stepOpen the step-by-step tutorial
Steps
  1. Run the local MCP process.
  2. Send the name_to_smiles request.
  3. Retain the source and returned SMILES before local analysis.

CheckAspirin returns a PubChem-backed isomeric SMILES.

If it does not workThis is the only MCP tool that sends input to a network service.

tools/call: name_to_smiles
name: aspirin
Open guide

AI agents

Canonicalize SMILES before matching local records

Return chematic's canonical SMILES locally, then retain it with the input and the software version.

What you will makeA versioned local canonical-SMILES recordNext stepOpen the step-by-step tutorial
Steps
  1. Run the local MCP process.
  2. Send the canonical_smiles request.
  3. Keep the input, canonical output, and version together.

CheckThe response contains a canonical SMILES string without a network request.

If it does not workDo not treat canonical strings from different libraries or releases as interchangeable without validation.

tools/call: canonical_smiles
smiles: C1=CC=CC=C1
Open guide

Python

Flag duplicate structures in a SMILES CSV

Keep every CSV row and label local duplicate candidates from chematic's canonical SMILES.

What you will makeA row-preserving duplicate-review CSVNext stepOpen the step-by-step tutorial
Steps
  1. Read a CSV with a smiles column.
  2. Write canonical SMILES and a row status.
  3. Review duplicate candidates before deleting data.

CheckCCO and OCC share C(C)O; the later row is flagged as a duplicate candidate.

If it does not workCanonical strings are not universal identity proof; retain original rows and version information.

chematic.from_smiles(smiles).smiles
Open guide

Python

Standardize salts before a duplicate review

Keep the submitted SMILES and create a separate, policy-defined review representation for salt-containing records.

What you will makeA source-preserving standardization reportNext stepOpen the step-by-step tutorial
Steps
  1. Keep the source SMILES unchanged.
  2. Standardize a separate review value locally.
  3. Compare only under the recorded policy.

CheckSodium acetate and acetic acid both yield CC(O)=O for a largest-fragment review.

If it does not workNever replace the submitted salt form or stereochemical record with the review representation.

mol.standardize(largest_fragment_only=True)
Open guide

Python

Preflight a SMILES list before a batch workflow

Classify every source value before a batch API can skip an invalid row.

What you will makeAn input-order-preserving preflight reportNext stepOpen the step-by-step tutorial
Steps
  1. Load source SMILES in row order.
  2. Record accepted and rejected results.
  3. Map input_index back to the source before the next workflow.

CheckCCO and OCC are accepted; incomplete C1CC remains rejected at input_index 1.

If it does not workSyntax acceptance does not prove chemical identity, salt policy, safety, or experimental validity.

canonicalize_smiles_batch_json(source_smiles)
Open guide

Python

Export a SMILES structure as an SVG file in Python

Create a scalable local 2D structure artifact while retaining the exact source SMILES.

What you will makeA traceable aspirin.svg fileNext stepOpen the step-by-step tutorial
Steps
  1. Parse one complete SMILES locally.
  2. Write the SVG depiction as UTF-8 text.
  3. Keep input and package version with the artifact.

Checkaspirin.svg opens as a scalable 2D structure drawing.

If it does not workAn SVG drawing is not chemical identity, stereochemical, safety, or experimental proof.

Path("aspirin.svg").write_text(mol.svg())
Open guide

Python

Export a reaction SMILES diagram as SVG in Python

Create a local scalable reaction diagram from one explicit reaction SMILES string.

What you will makeA traceable esterification.svg diagramNext stepOpen the step-by-step tutorial
Steps
  1. Set a reaction SMILES in reactants>>products form.
  2. Write the SVG diagram as UTF-8 text.
  3. Keep the reaction SMILES and package version with the artifact.

Checkesterification.svg opens with reactants, an arrow, and products.

If it does not workA reaction SVG is not proof of atom mapping, balance, conditions, yield, identity, safety, or experimental validity.

Path("esterification.svg").write_text(chematic.reaction_svg(...))
Open guide

Python

Write an SDF record from SMILES in Python

Create a local SDF record with a name and exact source SMILES retained as SD data.

What you will makeA traceable ethanol.sdf recordNext stepOpen the step-by-step tutorial
Steps
  1. Parse one complete SMILES locally.
  2. Set the record name and source SMILES as properties.
  3. Write and inspect one SDF record.

Checkethanol.sdf contains the ethanol record, source_smiles: CCO, and a $$$$ terminator.

If it does not workAn SDF record and generated 2D coordinates do not prove chemical identity, material provenance, safety, or experimental validity.

with chematic.SDWriter("ethanol.sdf") as writer:
    writer.write(mol)
Open guide

Python

Create an SDF library from a SMILES CSV in Python

Write valid CSV rows as local SDF records and keep every source row in a report.

What you will makemolecules.sdf plus molecule-report.csvNext stepOpen the step-by-step tutorial
Steps
  1. Read name and smiles from a CSV.
  2. Write valid records with source-row properties.
  3. Keep invalid rows in a CSV report.

CheckValid rows create SDF records; C1CC remains as invalid_smiles in the report.

If it does not workSDF output does not prove identity, provenance, safety, or experimental validity.

chematic.SDWriter("molecules.sdf")
Open guide