streamlit-markdown-editor
A Streamlit component providing a dual-mode (WYSIWYG ⇄ raw) markdown editor — markdown in, markdown out. Edit in a rich WYSIWYG surface or toggle to the raw CommonMark source; both stay in sync over one canonical string.
What it is
A Streamlit input widget for editing markdown in two synchronized modes:
- WYSIWYG (rendered) — powered by Milkdown. You see formatted content, not syntax: format with the usual keyboard shortcuts (⌘/Ctrl-B, …) and markdown input rules (type
#for a heading,-for a list; GFM tables), which convert to rendered elements as you type. There is no formatting toolbar. - Raw — the CommonMark source as plain text, powered by CodeMirror 6 with markdown syntax highlighting.
A toggle above the editor switches modes; the two views stay in sync over a single canonical markdown string, and the caret is carried across a switch on a best-effort (line/column) basis. The widget takes markdown in and returns markdown out — nothing else to wire up.
Installation
pip install streamlit-markdown-editor
# or
uv add streamlit-markdown-editor
Quickstart
import streamlit as st
from streamlit_markdown_editor import st_markdown_editor
# Markdown in, markdown out: pass the initial markdown, get the edited markdown back.
markdown = st_markdown_editor("# Hello\n\nStart typing…", key="editor")
st.markdown(markdown)
Run it with streamlit run app.py. The editor loads the markdown you pass as
value and returns the current markdown on every rerun — equal to value on the
first render (before any edit) and the edited markdown thereafter. Use the toggle
above the editor to switch between the WYSIWYG and raw views.
API reference
st_markdown_editor(
value: str = "",
*,
key: str | None = None,
equivalent: Callable[[str, str], bool] | None = None,
width: int | Literal["stretch", "content"] = "stretch",
height: int | Literal["stretch", "content"] = "content",
) -> str
| Parameter | Description |
|---|---|
value |
The markdown to load into the editor. On reruns, pass the markdown you want reflected; the editor reconciles an external change against any in-progress edit. Defaults to "". |
key |
A stable widget key. Use it to render more than one editor on a page, or to preserve editor state across reruns. Required when equivalent is set. |
equivalent |
equivalent(candidate, current) -> bool — decides whether an inbound value is a genuine external change or an echo of the editor's own output (your canonicalization / equality). When provided, key is required. Omitted → byte-equality. |
width |
Component width: a pixel int, "stretch" (default, fills the container), or "content". |
height |
Component height: a pixel int, "content" (default, fits the content), or "stretch". |
Returns str — the current markdown: equal to value on the first render (before any edit), and the edited markdown thereafter.
Passing equivalent without key raises StreamlitAPIException. For the full
reference, see help(st_markdown_editor).
When to use equivalent. By default the editor uses byte-equality to tell its
own output apart from a value you pass in — all you need when you feed the returned
markdown straight back as value. If your app transforms the markdown between
reruns (canonicalizing or reformatting it before passing it back), byte-equality
breaks: the reformatted echo looks like a brand-new external value on every rerun,
so the editor keeps re-loading it and clobbering the user's cursor and in-progress
edits. Supply equivalent(candidate, current) to define when two markdown strings
count as the same document (your normalization) — then a reformatted echo is
recognized as an echo and left alone, while a genuinely new value is still
adopted. Most apps don't need it.
Example
A runnable demo is in examples/app.py — two panels covering the
plain round-trip and the inbound-reconcile (equivalent) behavior:
streamlit run examples/app.py
Requirements
- Python ≥ 3.10
- Streamlit ≥ 1.60 (for the v2 components API)
License
MIT — see LICENSE.
Metadata
Release files for streamlit-markdown-editor 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| streamlit_markdown_editor-0.1.1.tar.gz | 665.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| streamlit_markdown_editor-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.1 MB
Release files / streamlit_markdown_editor-0.1.1.tar.gz
| Download URL | streamlit_markdown_editor-0.1.1.tar.gz |
|---|---|
| Size | 665.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
227db9d61e936b38f7ed1ac87b82fe76dbb20454012266b6f3694311b22441a4
|
|
BLAKE2b-256 checksum How to use checksums |
eef3ff9b254c0c040d9f347e1b93a6ce818114a8b8570a03ae8f02d839d72a2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 25, 2026.
Transparency logRelease files / streamlit_markdown_editor-0.1.1-py3-none-any.whl
| Download URL | streamlit_markdown_editor-0.1.1-py3-none-any.whl |
|---|---|
| Size | 391.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f6545ba60fce0771ddc0a1c5c8d999482403ddff55d30b67cae5d62c28946377
|
|
BLAKE2b-256 checksum How to use checksums |
d431d56b6fe8cdf926d169e82c23fd58fad3a09ba1ba74f40a848c6bf6d2010f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 25, 2026.
Transparency log