Ketcher is an open-source web-based chemical structure editor incorporating high performance, good portability, light weight, and ability to easily integrate into a custom web-application. Ketcher is designed for chemists, laboratory scientists and technicians who draw structures and reactions.
At this moment Ketcher can be embedded into your application in two ways:
npm install ketcher-core ketcher-react
import { Editor } from 'ketcher-react';
import { StandaloneStructServiceProvider } from 'ketcher-standalone';
import 'ketcher-react/dist/index.css';
const structServiceProvider = new StandaloneStructServiceProvider();
function App() {
return (
<Editor
staticResourcesUrl="/public"
structServiceProvider={structServiceProvider}
onInit={(ketcher) => {
window.ketcher = ketcher;
}}
/>
);
}
Look at the following link for details.
You can find the instruction for service installation here.
| Project | Status | Description |
|---|---|---|
| ketcher-core | Core functionality: domain, shared services, functions and interface declarations | |
| ketcher-standalone | Contains only the functionality necessary to start Ketcher in standalone mode | |
| ketcher-react | Package contains only the functionality necessary to define components. | |
| ketcher-macromolecules | Package contains the macromolecules editor functionality and UI components |
Ketcher uses Miew-React for viewing and editing data in 3D.
You can find the latest version of Miew-React here. The last checked version - 1.0.0.
Starting with version 3.0, Ketcher supports a new control in the top toolbar that allows switching to macromolecules editing mode. If you prefer having only small molecules editing mode available, you can remove the mode switcher from the toolbar by passing disableMacromoleculesEditor property to the Editor component.
import { Editor } from 'ketcher-react';
const App = () => {
return (
<Editor
{/* ...rest of the properties */}
disableMacromoleculesEditor
/>
);
};
Please refer to the example/src/App.tsx file for a complete example of how to integrate Ketcher editor into your application.
All export methods return Promise<string> with the structure in the requested format.
getSmiles(isExtended?: boolean): Promise<string>
Returns SMILES (Simplified Molecular Input Line Entry System) representation.
Parameters:
- isExtended (optional) - Use extended SMILES format (default: false)
Throws: Error in macromolecules mode
Example:
const smiles = await ketcher.getSmiles();
// Returns: "C1=CC=CC=C1"
const extended = await ketcher.getSmiles(true);
// Returns extended SMILES with stereochemistry
getExtendedSmiles(): Promise<string>
Alias for getSmiles(true).
getMolfile(molfileFormat?: 'v2000' | 'v3000'): Promise<string>
Returns MDL MOL file format.
Parameters:
- molfileFormat (optional) - MOL file version: 'v2000', 'v3000', or auto-detect
Throws: Error if structure contains reaction arrows (use getRxn instead)
Example:
const mol = await ketcher.getMolfile('v3000');
getRxn(molfileFormat?: 'v2000' | 'v3000'): Promise<string>
Returns RXN (Reaction) file format.
Parameters:
- molfileFormat (optional) - RXN file version (default: 'v2000')
Throws: - Error if no reaction arrows present - Error in macromolecules mode
Example:
const rxn = await ketcher.getRxn('v3000');
getKet(): Promise<string>
Returns KET (Ketcher JSON) format - the native internal format.
Works in both micro and macromolecules modes.
Example:
const ket = await ketcher.getKet();
const ketObj = JSON.parse(ket);
getSmarts(): Promise<string>
Returns SMARTS (SMILES Arbitrary Target Specification) representation.
Throws: Error in macromolecules mode
getCml(): Promise<string>
Returns CML (Chemical Markup Language) format.
Throws: Error in macromolecules mode
getSdf(molfileFormat?: 'v2000' | 'v3000'): Promise<string>
Returns SDF (Structure-Data File) format.
Parameters:
- molfileFormat (optional) - Version (default: 'v2000')
Throws: Error in macromolecules mode
getRdf(molfileFormat?: 'v2000' | 'v3000'): Promise<string>
Returns RDF (Reaction Data File) format.
Parameters:
- molfileFormat (optional) - Version (default: 'v2000')
Throws: Error in macromolecules mode
getCDXml(): Promise<string>
Returns CDXML (ChemDraw XML) format.
Throws: Error in macromolecules mode
getCDX(): Promise<string>
Returns CDX (ChemDraw binary) format as base64-encoded string.
Throws: Error in macromolecules mode
getInchi(withAuxInfo?: boolean): Promise<string>
Returns InChI (IUPAC International Chemical Identifier) representation.
Parameters:
- withAuxInfo (optional) - Include auxiliary information (default: false)
Example:
const inchi = await ketcher.getInchi();
// Returns: "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"
getInChIKey(): Promise<string>
Returns InChI Key (hashed InChI).
Example:
const key = await ketcher.getInChIKey();
// Returns: "UHOVQNZJYSORNB-UHFFFAOYSA-N"
getFasta(): Promise<string>
Returns FASTA format for biological sequences.
Available in macromolecules mode.
getSequence(format: '1-letter' | '3-letter'): Promise<string>
Returns sequence in 1-letter or 3-letter amino acid/nucleotide format.
Parameters:
- format - Sequence format: '1-letter' or '3-letter'
Example:
const seq = await ketcher.getSequence('1-letter');
// Returns: "ACDEFG"
getIdt(): Promise<string>
Returns IDT (Integrated DNA Technologies) format.
getAxoLabs(): Promise<string>
Returns AxoLabs format.
setMolecule(structure: string, options?: SetMoleculeOptions): Promise<void>
Loads structure onto canvas, replacing existing structure.
Parameters:
- structure - Structure string (format auto-detected)
- options (optional) - Import options
SetMoleculeOptions:
interface SetMoleculeOptions {
position?: { x: number; y: number }; // Top-left corner in Angstroms (Y increases upward)
needZoom?: boolean; // Zoom to fit (default: true)
}
Automatically centers and zooms to fit structure.
Example:
// Load SMILES
await ketcher.setMolecule('C1=CC=CC=C1');
// Load at specific position
await ketcher.setMolecule('CCO', {
position: { x: 5, y: 5 },
needZoom: false
});
// Load MOL file
const molfile = `...`;
await ketcher.setMolecule(molfile);
// Load KET
const ket = JSON.stringify({ root: { nodes: [...] } });
await ketcher.setMolecule(ket);
addFragment(structure: string, options?: SetMoleculeOptions): Promise<void>
Adds structure to canvas without removing existing content.
Parameters: Same as setMolecule
Example:
await ketcher.setMolecule('C1=CC=CC=C1');
await ketcher.addFragment('CCO', { position: { x: 10, y: 0 } });
setHelm(helmStr: string): Promise<void>
Loads HELM (Hierarchical Editing Language for Macromolecules) notation structure.
Example:
await ketcher.setHelm('PEPTIDE1{A.G.F}$$$$V2.0');
layout(): Promise<void>
Performs automatic layout algorithm using Indigo service for smart positioning.
Throws: Error in macromolecules mode
Example:
await ketcher.layout();
circularLayoutMonomers(): Promise<void>
Arranges monomers in circular layout.
Only available in macromolecules mode.
calculate(options?: CalculateData): Promise<CalculateResult>
Calculates molecular properties.
Returns:
interface CalculateResult {
'molecular-weight': string;
'most-abundant-mass': string;
'monoisotopic-mass': string;
'gross': string; // Molecular formula
'mass-composition': string;
}
Throws: Error in macromolecules mode
Example:
const props = await ketcher.calculate();
console.log('Molecular weight:', props['molecular-weight']);
console.log('Formula:', props['gross']);
```typescript recognize(image: Blob, version?: s
$ claude mcp add ketcher \
-- python -m otcore.mcp_server <graph>