Skip to main content

demangle

CI Python Licence Docs Open Playground

Read mangled symbol names in pure Python. Itanium C++ (GCC, Clang), MSVC, Rust, Swift, Objective-C, Go, D, Nim, Free Pascal, Delphi and C++Builder, Ada/GNAT, JNI, and the pre-Itanium C++ families (g++ 2.x, cfront/ARM, Lucid, HP aCC, CodeWarrior), with no dependencies and no native code.

>>> import demangle
>>> demangle.demangle("_ZNSt6vectorIiSaIiEE9push_backERKi")
'std::vector<int, std::allocator<int>>::push_back(int const&)'
>>> demangle.demangle("?f@@YAXH@Z")
'void __cdecl f(int)'
>>> demangle.demangle("_ZN4core3fmt9Formatter3pad17h9b2b3a0e5b4d1b31E")
'core::fmt::Formatter::pad'
>>> demangle.demangle("$s10Foundation4DataV5countSivg")
'Foundation.Data.count.getter : Swift.Int'
>>> demangle.demangle("@Unit@Class@Method$qqrv")
'__fastcall Unit::Class::Method()'
>>> demangle.demangle("CreateFileW")    # not mangled, so returned as it is
'CreateFileW'
  • One wheel, everywhere. Pure Python on CPython 3.11+ and PyPy, and in the browser through Pyodide. Nothing to compile at install time and no native library to find at run time.
  • A tree, not just a string. parse() returns nodes to walk and signature() the parts of a name, so nothing has to take a C++ declaration apart with a regular expression.
  • Measured against the references. Every scheme is scored against its reference demangler (llvm-cxxfilt, GNU c++filt, llvm-undname, rustc-demangle, swift-demangle and others) or, where there is none, against what the compiler recorded, over checked-in corpora and about 2,500,000 real symbols.
  • Safe on hostile input. Recursion depth, output size, substitution count and input length are bounded while a name is read, and demangle() never raises over a name.

Install

pip install demangle

Quick start

demangle() returns the spelling, or the name unchanged when nothing reads it, so it is safe to run over every symbol in a binary. When you need more than the string:

>>> demangle.parse("_ZNK3Foo3barIiEEvPKc").spell()           # a tree; raises if unreadable
'void Foo::bar<int>(char const*) const'
>>> demangle.signature("_ZNSt6vectorIiSaIiEE9push_backERKi").base_name
'push_back'
>>> demangle.demangle_text("0000000000001139 T _ZN3foo3barEv")   # every symbol in a line
'0000000000001139 T foo::bar()'
>>> demangle.demangle("_ZNSt6vectorIiSaIiEE9push_backERKi", style="gnu")
'std::vector<int, std::allocator<int> >::push_back(int const&)'

The command is a filter like c++filt, over any mix of schemes:

$ nm -D libfoo.so | demangle
$ demangle '?f@@YAXH@Z' _RNvC6_123foo3bar
$ nm -D libfoo.so | demangle --json-lines       # one JSON object per symbol

Scripts for IDA Pro, Binary Ninja and Ghidra relabel a database with it, and the playground runs it in the browser.

Documentation

The full documentation is at https://r0ny123.github.io/demangle/.

Page What it covers
Using the library Every entry point, styles and options, and the command line
Working with the tree One real task through parse(), against the regular-expression version
Labelling a symbol table One label per address, the same whichever compiler built the binary
API reference Signatures and docstrings
Conformance What each scheme is measured against, and every number
Comparison Coverage and speed beside LLVM, cpp_demangle and itanium_demangler
Security policy The threat model, the bounds, and how to report privately
Architecture How the parsers, builders and schemes fit together

Performance

Measured on the conformance corpora by benchmarks/bench.py, whose --check gates CI against benchmarks/baseline.json:

Workload Throughput
Cold, every name distinct ~22,000 names/s
Warm, names repeat as in a real symbol table ~2,700,000 names/s
Names that are not mangled ~1,200,000 names/s
Full tree construction ~18,000 names/s

On names it has not seen, a native demangler is an order of magnitude or more faster: LLVM's reads libstdc++'s Itanium names about 50 times as fast. A symbol table repeats its names, though, and a name read once costs a dictionary lookup afterwards.

Contributing

New schemes, corpus entries and conformance reports are welcome; see CONTRIBUTING.md, or report a wrong spelling.

Licence

MIT. The Rust and MSVC readers derive from MIT- and BSD-licensed originals; NOTICE has the details.

Metadata

Release files for demangle 0.7.1

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

Source distribution (sdist)

Source distribution for demangle 0.7.1
File Size Uploaded Provenance Actions
demangle-0.7.1.tar.gz 3.3 MB With provenance Details for demangle-0.7.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for demangle 0.7.1
File Interpreter ABI Platform Actions
demangle-0.7.1-py3-none-any.whl Python 3 none any Details for demangle-0.7.1-py3-none-any.whl

Total release size: 3.8 MB

Release files / demangle-0.7.1.tar.gz

Download URL demangle-0.7.1.tar.gz
Size 3.3 MB
Tags Source
SHA-256 checksum
How to use checksums
fd1ce917c3a968b756ce1f691703f5cfdf789a52316611f9aff0f3546a7b8d81
BLAKE2b-256 checksum
How to use checksums
5b42b24d1316e9f5091d341e7a5effbefc5c5c702e91c6d11e34dc973cbb55b2
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 13, 2026.

Transparency log

Release files / demangle-0.7.1-py3-none-any.whl

Download URL demangle-0.7.1-py3-none-any.whl
Size 464.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1fb5210535ce9e930bd244fa598bd3944776093081dee864f58ca46348c7dcf
BLAKE2b-256 checksum
How to use checksums
2e1ee6b3c4a73d5d73da74db753233fda9febd600759dccdc7fe54cd345f8dd7
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 13, 2026.

Transparency log

Security for demangle 0.7.1

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 demangle-0.7.1.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 13, 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.

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