Skip to main content

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

The streamlit-markdown-editor in WYSIWYG mode

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.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 streamlit-markdown-editor 0.1.0
File Size Uploaded
streamlit_markdown_editor-0.1.0.tar.gz 665.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-markdown-editor 0.1.0
File Interpreter ABI Platform
streamlit_markdown_editor-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.1 MB

Release files / streamlit_markdown_editor-0.1.0.tar.gz

Download URL streamlit_markdown_editor-0.1.0.tar.gz
Size 665.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d3b580360c31eb38561c2136b83eb907c812cf814759483944cbfde86704d6f8
BLAKE2b-256 checksum
How to use checksums
0fa898cebd262eef841930f38d4e8dd18bd70619d54c5f9505986e924f9da15a
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

Release files / streamlit_markdown_editor-0.1.0-py3-none-any.whl

Download URL streamlit_markdown_editor-0.1.0-py3-none-any.whl
Size 391.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a77c3a8e4c8aa182d5809ab96a468d162b052e071317f6bcc99d22f7261843a
BLAKE2b-256 checksum
How to use checksums
c76213ffb082da7f372f6266bfae26a1a5d71d54ca7f9e914f951ad5d1e362e2
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

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

0.0.0

2 release files

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