spglib

Detection and handling of crystal symmetry; a dependency of very many codes.

Tool 087 of 100 in the MolForge directory of open-source tools. Every fact below was read from the repository's host on 2026-11-28.

spglib, open-source tool for crystallography: Detection and handling of crystal symmetry; a dependency of very many codes.

What spglib is

spglib is a C library, with Python and Fortran bindings among others, that determines the symmetry of a crystal structure. Given lattice vectors, fractional atomic positions and atom types, it finds the space group (the set of rotations and translations that map the crystal onto itself), lists the symmetry operations, assigns Wyckoff positions and site symmetries, and produces standardised or primitive cells. It also generates irreducible k-point meshes and detects magnetic space groups when magnetic moments are supplied.

Most users never call spglib directly. It sits underneath phonopy, pymatgen's SpacegroupAnalyzer, ASE and many electronic structure and materials codes that need symmetry. Direct use from Python takes a tuple of lattice, positions and numbers and returns a dataset with the international symbol, Hall number, rotation matrices, translations, equivalent atoms and Wyckoff letters, all controlled by a distance tolerance.

spglib works on arrays, not files; reading CIF or POSCAR is left to the calling library. The tolerance choice matters: too tight misses symmetry in relaxed structures, too loose merges distinct atoms.

Features

What it is for

Verified facts

FamilyCrystallography
Language or basisC, Python
Repositoryhttps://github.com/spglib/spglib (GitHub)
LicenceBSD-3-Clause (SPDX identifier as declared in the repository)
Main language on GitHubC
Last commit2026-11-25
Latest releasev2.8.0 (2026-10-14)
Stars379 on 2026-11-28
Open issues and pull requests77 on 2026-11-28
Repository created2013-06-17
Verified2026-11-28 by MolForge's checking script, against the host's API

Where spglib fits

Symmetry, diffraction and macromolecular file handling.

spglib appears in this chain of the directory: High-throughput materials screening by DFT.

Our comments on spglib

MolForge does not run spglib in production. This page is a verified pointer, not a review: the facts above come from the repository on the date shown, the description is ours, and we make no claim about accuracy or speed that we have not measured. If you maintain spglib and something here is wrong or out of date, write to hello@molforge.ai and we will correct the source file.

Test status

Not tested by MolForge. To check spglib yourself: clone the repository, follow the installation section of its README, and run the test suite the project ships before trusting a result; the last-commit date and the open issue count above tell you how alive the project is.

Questions people ask

Why does spglib report a different space group than I expected?
Usually the tolerance. The symprec parameter sets how far atoms may deviate from ideal positions and still count as symmetric; relaxed or thermally distorted structures need a looser value, while too loose a value merges distinct atoms. Running with a few tolerances and checking where the result changes is standard practice.
Does spglib read CIF or POSCAR files?
No. spglib takes arrays of lattice vectors, fractional positions and atom types. Libraries such as ASE, pymatgen and phonopy read the files, pass the arrays to spglib and wrap the results, which is why most users meet spglib through one of them rather than directly.
Can spglib handle magnetic structures?
Yes. When magnetic moments are supplied, collinear or non-collinear, spglib determines the magnetic space group and the operations that preserve both atomic positions and moments, including time-reversal combinations. The standard non-magnetic analysis ignores moments, so the magnetic functions must be called explicitly.
Is spglib a Python package?
It is a C library with an official Python binding installed from PyPI or conda-forge; the Python package bundles the compiled library, so no separate build is needed. Fortran bindings are maintained in the same repository, and the C API can be linked from any language.
Is spglib open source?
Yes. The repository declares the BSD-3-Clause licence (SPDX identifier read from the host on 2026-11-28). Read the licence text in the repository before redistributing or embedding it.
Where is the spglib source code?
At https://github.com/spglib/spglib (GitHub). This is the address the host reported on the day of verification; renamed repositories are followed to their new home.
Is spglib still maintained?
The last commit was pushed on 2026-11-25 and the latest tagged release is v2.8.0 from 2026-10-14; the repository had 77 open issues and pull requests on 2026-11-28.
Does MolForge use spglib?
No. MolForge runs nine of the hundred tools in this directory (RDKit, OpenMM, AutoDock Vina, Open Babel, MDTraj, pymbar and NGL, plus PySCF and xTB in MFsig); spglib is listed because of its place in crystallography, not because we run it.

Guides that explain the methods

Other tools in crystallography