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.8.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 demangle 0.8.0
File Size Uploaded Provenance Actions
demangle-0.8.0.tar.gz 3.3 MB With provenance Details for demangle-0.8.0.tar.gz

Built distribution (wheel)

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

Total release size: 3.8 MB

Release files / demangle-0.8.0.tar.gz

Download URL demangle-0.8.0.tar.gz
Size 3.3 MB
Tags Source
SHA-256 checksum
How to use checksums
0860be1497145f4bfc6088e569187cdcd1e7e13d23f6aa37bcf6f66b6207824c
BLAKE2b-256 checksum
How to use checksums
0f35086c23096776613385e8f74652fba373ce6f42542140eda969fe5482e1d8
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.8.0-py3-none-any.whl

Download URL demangle-0.8.0-py3-none-any.whl
Size 466.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a127f5ba7a18c775056d51b75e8838abf9236330fb85efb36773d9e9ae106f03
BLAKE2b-256 checksum
How to use checksums
17ca180d1acfe58994b7ecaa92013a05d5187e0ebb4a59e62036a128475e3e16
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.8.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 demangle-0.8.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 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