skillfed

sphinx-copybutton

Add a copy button to each of your code cells.

sphinx-copybutton v0.5.2 7.8M downloads/30d#1,697 on PyPI270
Permissive license MIT License Active released

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-copybutton

uv

uv add sphinx-copybutton

poetry

poetry add sphinx-copybutton

Installing 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

Framework :: Sphinx :: ExtensionLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

sphinx code block copy buttonsphinx documentation copy codesphinx extension code copyingadd copy button to code blockssphinx code snippet clipboarddocumentation code block uisphinx interactive code blocks
sphinx-extensiondocumentation-ui

More Sphinx packages

docstring-parser

Parses Python docstrings in ReST, Google,…

permissive · top 1,000 on PyPI

Sphinx

Sphinx generates professional documentation…

permissive · top 1,000 on PyPI

sphinxcontrib-serializinghtml

A Sphinx extension that outputs documentation…

permissive · top 1,000 on PyPI

alabaster

Alabaster is a clean, responsive Sphinx theme…

permissive · top 1,000 on PyPI

sphinxcontrib-htmlhelp

A Sphinx extension that generates HTML help…

permissive · top 1,000 on PyPI

sphinxcontrib-qthelp

A Sphinx extension that converts documentation…

permissive · top 1,000 on PyPI

sphinx-toggleprompt

Adds a button to Python code blocks in Sphinx…

permissive · top 15,000 on PyPI

sphinx-togglebutton

A Sphinx extension that adds collapsible toggle…

permissive · top 15,000 on PyPI

sphinx-panels

A Sphinx extension that adds directives for…

permissive · top 15,000 on PyPI

sphinx-thebe

Adds interactive, executable code blocks to…

unclear · top 15,000 on PyPI

jupyter-sphinx

Jupyter Sphinx Extensions runs code embedded in…

unclear · top 15,000 on PyPI

sphinx-inline-tabs

Adds tabbed content blocks to Sphinx…

permissive · top 15,000 on PyPI

sphinx-tabs

A Sphinx extension that adds tabbed content…

permissive · top 5,000 on PyPI

sphinx-multitoc-numbering

A Sphinx extension that maintains continuous…

permissive · top 15,000 on PyPI

sphinx-codeautolink

sphinx-codeautolink automatically converts code…

unclear · top 15,000 on PyPI

sphobjinv

Inspect, search, and manipulate Sphinx…

permissive · top 15,000 on PyPI