sphinx-copybutton
Add a copy button to each of your code cells.
What it is and what it does
sphinx-copybutton is a lightweight Sphinx extension that enhances code blocks in documentation by adding a clickable copy button. When readers click the button, the code block's content is copied to their clipboard. The extension integrates directly into Sphinx's build process and requires only a single line addition to your documentation configuration file.
The package relies on the clipboard.js library for its JavaScript functionality and is designed to work with modern Python versions. It's widely used in documentation projects and has accumulated significant download volume, indicating stable, practical utility for documentation authors who want to improve the reader experience when sharing code examples.
Use it for:
- Add copy buttons to code examples in API documentation so users can quickly copy sample calls
- Enhance tutorial documentation where readers need to copy and paste setup commands or code snippets
- Improve user experience in technical guides by reducing friction when copying multi-line code blocks
- Enable one-click code copying in Jupyter Book or MyST Markdown documentation built with Sphinx
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Sphinx extension that adds a copy button to code blocks in documentation, allowing readers to quickly copy code snippets to their clipboard.
Yes. This is a low-friction, actively maintained extension that solves a genuine user experience problem in documentation. With no security vulnerabilities, a permissive license, and a single dependency on Sphinx itself, it's a straightforward addition to any Sphinx-based documentation project.
Install
sphinx-copybutton on PyPI
pip
pip install sphinx-copybuttonuv
uv add sphinx-copybuttonpoetry
poetry add sphinx-copybuttonInstalling sphinx-copybutton
Before you install
Low friction installation with a single runtime dependency on sphinx. The package is actively maintained with recent commits and has been stable since its early releases.
License in practice
MIT License permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial documentation projects.
Quickstart
pip install sphinx-copybutton
# In conf.py:
extensions = [
'sphinx_copybutton'
]
Verify before relying
- Whether the copy button appearance and behavior can be customized beyond CSS overrides
- Browser compatibility and JavaScript runtime requirements for the clipboard functionality
Package facts
| License | MIT License (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — sphinx |
| Maintenance | actively maintained — 1,218 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 7,777,753/month — #1,697 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sphinx_copybutton-0.5.2-py3-none-any.whl
Tags
More Sphinx packages
Parses Python docstrings in ReST, Google,…
permissive · top 1,000 on PyPI
SphinxSphinx generates professional documentation…
permissive · top 1,000 on PyPI
sphinxcontrib-serializinghtmlA Sphinx extension that outputs documentation…
permissive · top 1,000 on PyPI
alabasterAlabaster is a clean, responsive Sphinx theme…
permissive · top 1,000 on PyPI
sphinxcontrib-htmlhelpA Sphinx extension that generates HTML help…
permissive · top 1,000 on PyPI
sphinxcontrib-qthelpA Sphinx extension that converts documentation…
permissive · top 1,000 on PyPI
sphinx-togglepromptAdds a button to Python code blocks in Sphinx…
permissive · top 15,000 on PyPI
sphinx-togglebuttonA Sphinx extension that adds collapsible toggle…
permissive · top 15,000 on PyPI
sphinx-panelsA Sphinx extension that adds directives for…
permissive · top 15,000 on PyPI
sphinx-thebeAdds interactive, executable code blocks to…
unclear · top 15,000 on PyPI
jupyter-sphinxJupyter Sphinx Extensions runs code embedded in…
unclear · top 15,000 on PyPI
sphinx-inline-tabsAdds tabbed content blocks to Sphinx…
permissive · top 15,000 on PyPI
sphinx-tabsA Sphinx extension that adds tabbed content…
permissive · top 5,000 on PyPI
sphinx-multitoc-numberingA Sphinx extension that maintains continuous…
permissive · top 15,000 on PyPI
sphinx-codeautolinksphinx-codeautolink automatically converts code…
unclear · top 15,000 on PyPI
sphobjinvInspect, search, and manipulate Sphinx…
permissive · top 15,000 on PyPI