Skip to main content

smiles-to-iupac

PyPI Python License: MIT

Alpha release. Coverage of the Blue Book is incomplete and growing. Unsupported structures raise UnsupportedStructure; names should still be checked before use in anything that matters.

Rule-based conversion of SMILES strings to IUPAC names, implemented directly from the Nomenclature of Organic Chemistry: Recommendations and Preferred Names 2013 (the "Blue Book"). No machine learning, no lookup table of known names: every name is constructed by applying the written rules.

>>> from smiles_to_iupac import smiles_to_iupac
>>> smiles_to_iupac("CC(C)C(CC)CCC")
'3-ethyl-2-methylhexane'
>>> smiles_to_iupac("CC(C)Cc1ccc(cc1)C(C)C(=O)O")
'2-[4-(2-methylpropyl)phenyl]propanoic acid'
>>> smiles_to_iupac("CN1CCC[C@H]1c1cccnc1")
'3-[(2S)-1-methylpyrrolidin-2-yl]pyridine'

Guiding principles

Two principles define the scope of this project and every change made to it.

1. Anything a SMILES string can express is in scope

The input is a SMILES string, so the goal is to name every molecule that SMILES can represent: acyclic and cyclic skeletons, fused, bridged and spiro ring systems, heterocycles, all common characteristic groups, charged and radical species, isotopes, stereochemistry, and organometallic and coordination compounds. What SMILES cannot express (for example, a free-standing locant set, a mixture description, or a polymer repeat unit with no defined structure) is out of scope by definition.

2. Names follow the rules written in the Blue Book

Behavior is derived from the text of the Blue Book rules, not from example outputs, third-party name generators, or database lookups. Worked examples and PubChem entries are used only to verify a result, never to define it.

  • If the Blue Book defines a preferred IUPAC name (PIN) for the structure, that PIN is returned.
  • If the Blue Book defines no PIN (for example, P-69.0 for most organometallics), a single rule-valid name is returned and a NonPreferredNameWarning is emitted, so the caller always knows when the result is valid but not preferred.
  • Where the Blue Book is itself contradictory, or a structure cannot be expressed unambiguously in SMILES, the structure is reported as unsupported rather than guessed.

What it covers

Rule coverage is organized by Blue Book chapter:

Blue Book chapter Covered
P-1 General principles: numerals, multiplying prefixes, locants, alphanumerical ordering, enclosing marks
P-2 Parent hydrides: acyclic and cyclic hydrocarbons, heteroatom skeletons (replacement "a" nomenclature), von Baeyer, spiro, fused (ortho-/peri-fused, heterocyclic), bridged, ring assemblies, phanes, fullerenes
P-3 Characteristic groups, substituent prefixes and suffixes, seniority of classes
P-4 Selection of the principal chain/ring, numbering and lowest locants, name assembly
P-5 Constructing names: functional replacement, added/indicated hydrogen, hydro/dehydro prefixes
P-6 Characteristic groups in names: alcohols, amines, carbonyls, acids and their derivatives (esters, amides, anhydrides, halides, nitriles), sulfur/selenium/tellurium and phosphorus acids, organometallic compounds
P-7 Radicals, ions and zwitterions, salts
P-8 Isotopically modified compounds
P-9 Stereodescriptors (R/S, E/Z, and related) and stereo-aware retained names
P-10 Natural products: carbohydrates, amino acids, nucleosides and nucleotides, lipids, and the Appendix 3 parent structures (alkaloids, steroids, terpenoids, carotenoids, tetrapyrroles, flavans) with their substituents, unsaturation and configuration

Beyond organic skeletons it also handles coordination and organometallic compounds (with NonPreferredNameWarning where the Blue Book defines no PIN), organoelement hydrides (B, Si, P, ...) and onium, carbocation and carbanion species.

Coverage grows rule by rule and is audited per rule. Structures that fall outside what is currently implemented raise UnsupportedStructure (see below); they are never silently mis-named.

Installation

Requires Python 3.10 or newer. Dependencies (RDKit and NetworkX) are installed automatically.

pip install smiles-to-iupac

From a clone of the repository:

pip install -e ".[dev]"

Usage

Python

import warnings
from smiles_to_iupac import smiles_to_iupac, NonPreferredNameWarning

smiles_to_iupac("c1ccc2[nH]ccc2c1")        # '1H-indole'
smiles_to_iupac("C[C@H](N)C(=O)O")         # 'L-alanine'
smiles_to_iupac("C1CC2CCC1C2")             # 'bicyclo[2.2.1]heptane'
smiles_to_iupac("CS(=O)(=O)O")             # 'methanesulfonic acid'

A name returned with NonPreferredNameWarning is valid under the Blue Book rules but is not a preferred IUPAC name:

with warnings.catch_warnings(record=True) as caught:
    warnings.simplefilter("always")
    name = smiles_to_iupac("[Fe]")          # 'iron'
    is_pin = not any(
        issubclass(w.category, NonPreferredNameWarning) for w in caught
    )

Alternative names

smiles_to_iupac returns one name, the preferred one where the Blue Book defines it. The general-nomenclature names the Blue Book allows next to it are returned by smiles_to_alternative_names, each labelled by kind and rule:

from smiles_to_iupac import smiles_to_alternative_names

smiles_to_alternative_names("CCC=NO")
# [AlternativeName(kind='functional-modifier', name='propanal oxime', rule='P-68.3.1.1.2')]

Kinds so far: functional-modifier (oxime, hydrazone, azine, semicarbazone, acetal, ketal and hemiacetal class names, P-15.2.2, P-66.6.5, P-68.3.1) and ionic-prefix (the onia, ylia, ida and uida skeletal replacement prefixes of charged heteroatoms, P-72.4, P-73.4) and conjunctive (a ring joined to the side chain that carries the principal group, as in benzeneacetic acid, P-15.6). The list is empty when no alternative applies. On the command line, smiles-to-iupac --alternatives CCC=NO prints <kind>\t<name> lines.

Errors

Every error the library defines derives from SmilesToIupacError, so one except SmilesToIupacError catches them all.

Exception Meaning
InvalidSmilesError Also a ValueError. The input is not a valid SMILES string. A non-str input raises TypeError.
UnsupportedStructure Also a NotImplementedError. The SMILES is valid but uses a rule that is not implemented yet: a gap that will be filled.
RuleUndefinedStructure Not an UnsupportedStructure. The Blue Book itself gives no single name for the structure (the rules leave it undefined or contradict each other), so waiting for more implementation will not help.
InternalInvariantError Also a RuntimeError. A bug, not a declined input: the naming pipeline contradicted itself, for example a name that lost a nuclide of its structure (P-82.2.1). Please report the SMILES.
from smiles_to_iupac import RuleUndefinedStructure, SmilesToIupacError, UnsupportedStructure, smiles_to_iupac

try:
    name = smiles_to_iupac(smiles)
except RuleUndefinedStructure:
    ...  # the Blue Book gives no name; retrying later will not help
except UnsupportedStructure:
    ...  # a rule that is not implemented yet
except SmilesToIupacError:
    ...  # invalid input or an internal error

Command line

smiles-to-iupac "CC(C)C(CC)CCC"            # 3-ethyl-2-methylhexane
smiles-to-iupac CCO c1ccncc1               # one "<smiles>\t<name>" line each
python3 -m smiles_to_iupac CCO             # equivalent module form

With a single SMILES only the name is printed. With several, each line is <smiles>\t<name>. Errors are written to stderr and the exit status is 1 if any input failed.

Development

pip install -e ".[dev]"
pytest                 # everything
pytest -m "not slow"   # what pull requests run: skips the few names that take over a second
ruff check .

When adding or changing behavior, derive it from the Blue Book rule text and cite the section number; use worked examples and PubChem only to check the result.

Citation

If you use this software in your work, please cite it:

@software{yoo_smiles_to_iupac,
  author = {Yoo, Inwan},
  title  = {smiles-to-iupac: Rule-based conversion of SMILES to IUPAC names},
  year   = {2026},
  url    = {https://github.com/iwyoo/smiles-to-iupac},
}

Please also cite the IUPAC recommendations the names are derived from: Favre, H. A.; Powell, W. H. Nomenclature of Organic Chemistry: IUPAC Recommendations and Preferred Names 2013; Royal Society of Chemistry, 2014.

References

See REFERENCES.md for the Blue Book source and chapter PDFs.

Disclaimer

This is an independent, unofficial implementation. It is not affiliated with, endorsed by, or certified by IUPAC or the Royal Society of Chemistry. The software is provided "as is", without warranty of any kind; generated names are not guaranteed to be correct or to be preferred IUPAC names.

Worked examples from the Blue Book are cited, in short form only, to verify behavior. Structures from PubChem (U.S. National Library of Medicine) are used only as a cross-check and never to produce names.

NISPO also generates names from structures. It is optimized for names that OPSIN parses back to the same structure, whereas this library follows the Blue Book, returning the preferred IUPAC name where one is defined and refusing structures it cannot name by the rules.

License

MIT — see LICENSE.

Metadata

Release files for smiles-to-iupac 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smiles-to-iupac 0.1.0
File Size Uploaded Provenance Actions
smiles_to_iupac-0.1.0.tar.gz 1.4 MB With provenance Details for smiles_to_iupac-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smiles-to-iupac 0.1.0
File Interpreter ABI Platform Actions
smiles_to_iupac-0.1.0-py3-none-any.whl Python 3 none any Details for smiles_to_iupac-0.1.0-py3-none-any.whl

Total release size: 2.9 MB

Release files / smiles_to_iupac-0.1.0.tar.gz

Download URL smiles_to_iupac-0.1.0.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
be807047dd187754f9dfc88cc44eccbd0e2e151dd8a7d3d39071f08b9e319ae2
BLAKE2b-256 checksum
How to use checksums
a81b78ba9274f94a297b97d02a23365429079189adcfdcf68945a6994fa90cfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / smiles_to_iupac-0.1.0-py3-none-any.whl

Download URL smiles_to_iupac-0.1.0-py3-none-any.whl
Size 1.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
92670e5105426259210c358c143afee94f7ebb1edfbb987df660cf976e4a8667
BLAKE2b-256 checksum
How to use checksums
f1c6baa9e57d98ed73b95130d040966c68a877190d9a54ff067a00d7e4f5f402
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for smiles-to-iupac 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for smiles_to_iupac-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page