Guides / Identifiers and formats

inchiinchikeychemical-identifiersrdkit

InChI and InChIKey explained, and when to use each

InChI is a layered, toolkit-independent structure identifier and InChIKey is its hashed form. Use InChI to carry structure and InChIKey to match records.

Updated 4 min read

InChI, the International Chemical Identifier, is a layered text identifier computed from a structure by one open algorithm, so every program that implements it produces the same string. InChIKey is a 27-character hash of that string, fixed in length and easy to search. Use InChI when you need to carry the structure itself in a toolkit-independent way, and InChIKey when you need to match records across databases or search the web. Neither replaces SMILES for day-to-day modelling, because neither is meant to be written or read by a person.

The layers of a standard InChI

An InChI is built from layers separated by slashes, each describing one aspect of the structure. Paracetamol reads:

InChI=1S/C8H9NO2/c1-6(10)9-7-2-4-8(11)5-3-7/h2-5,11H,1H3,(H,9,10)

The prefix InChI=1S says this is version 1 of the standard InChI. C8H9NO2 is the formula. The /c layer lists the connections between numbered heavy atoms. The /h layer places the hydrogens, and the group (H,9,10) marks one mobile hydrogen shared between atoms 9 and 10, the amide nitrogen and oxygen. That mobile-hydrogen treatment is how standard InChI folds some tautomers into one identifier.

Further layers appear only when needed. /q carries net charge and /p carries added or removed protons. /b records double-bond geometry, /t tetrahedral centres, /m whether the structure is inverted and /s the type of stereo information, absolute, relative or racemic. /i carries isotopes. A molecule with no stereocentres and natural isotopes simply has no such layers, which keeps simple identifiers short.

The S in 1S matters. Standard InChI fixes every option so that identifiers are comparable. Non-standard InChI, written InChI=1/, lets you switch on options such as keto-enol tautomer merging or fixed-hydrogen layers, at the price of comparability. Databases publish the standard form.

What the 27 characters of an InChIKey mean

Paracetamol's InChIKey is RZVAJINKPMORJF-UHFFFAOYSA-N. The first block of fourteen letters is a hash of the skeleton layers, formula, connections and hydrogens. The second block of ten letters hashes the remaining layers, stereo, isotopes and the rest, then appends a flag for standard InChI, S, and a version letter, A. The final letter encodes the protonation layer, with N meaning neutral. The hash is a truncated SHA-256, so a key cannot be decoded back into a structure. You must look it up.

The block structure is useful on its own. Ibuprofen with unspecified stereochemistry is HEFNNWSXXWATRW-UHFFFAOYSA-N, and (S)-ibuprofen is HEFNNWSXXWATRW-JTQLQIEISA-N. The first blocks match because the skeleton is identical, and the second blocks differ because one has a stereo layer. Searching on the first block alone therefore finds all stereoisomers and isotopologues of a compound at once. The string UHFFFAOYSA recurs across databases because it is the hash of an empty second block, the signature of a molecule with no stereo and no isotope layers.

InChI, InChIKey or SMILES

Each identifier answers a different need.

In practice a well-kept compound table stores all three, plus a database identifier such as a PubChem CID. Molecule Analysis accepts an InChIKey in its compound search for exactly this reason. It is the identifier most likely to survive a trip through someone else's spreadsheet.

Where InChI can surprise you

The mobile-hydrogen layer merges some tautomers and not others. 2-hydroxypyridine and 2-pyridone share one standard InChI, while a ketone and its enol do not, because keto-enol tautomerism is excluded from the standard. Two records that a chemist considers the same compound can therefore carry different keys, and two drawings a chemist considers different can carry the same key. The guide on tautomers and protonation states covers how to standardise before comparing.

InChI distinguishes a stereocentre that is unknown from one that is known to be undefined, which SMILES cannot do. It also carries no coordinates and no aromaticity, so converting InChI back to a structure gives you a graph, not a drawing. Finally, hash collisions between distinct structures are possible in principle, though none have been a practical problem for the compound collections in common use.

Computing both in RDKit

RDKit ships the InChI library, so one import covers everything:

from rdkit import Chem

mol = Chem.MolFromSmiles("CC(=O)Nc1ccc(O)cc1")   # paracetamol
inchi = Chem.MolToInchi(mol)
key = Chem.MolToInchiKey(mol)
print(inchi)   # InChI=1S/C8H9NO2/c1-6(10)9-7-2-4-8(11)5-3-7/h2-5,11H,1H3,(H,9,10)
print(key)     # RZVAJINKPMORJF-UHFFFAOYSA-N
print(Chem.InchiToInchiKey(inchi) == key)   # True

Chem.MolFromInchi reads the identifier back into a molecule. When you export results for colleagues, write the InChIKey in its own column next to the SMILES, a habit covered in the guide on exporting and sharing results.

Key points

Questions people ask

What is the difference between InChI and InChIKey?
InChI is a long, layered text string computed from a structure by one open algorithm, and it can be read back into the structure. InChIKey is a 27-character hash of the InChI that is fixed in length and easy to search but cannot be decoded. Use InChI to carry structure and InChIKey to match records.
Why do so many InChIKeys contain UHFFFAOYSA?
The second block of an InChIKey hashes the stereo, isotope and other optional layers. When a molecule has none of them, that block is the hash of an empty string, UHFFFAOY, followed by the standard flag S and the version letter A. Any molecule without stereo or isotope layers shows it.
Can two different molecules have the same InChIKey?
In principle yes, because any hash can collide, but collisions between real compounds have not been a practical problem for the compound collections in common use. Stereoisomers deliberately share the first fourteen characters and differ in the second block.
Is InChI better than SMILES?
They do different jobs. InChI is toolkit-independent and suited to exchange and archiving. SMILES is short, readable and the input every modelling tool expects. A well-kept compound table stores both, plus the InChIKey.

Further reading

In practice: The ADMET dashboard resolves a name, a PubChem CID or a SMILES to one compound and shows the identifiers side by side, so a mismatch is visible before anything is computed.

← All guides