String Utilities Alat telah diperbarui 4 hari yang lalu

Markdown Remove Code Blocks

Markdown Remove Code Blocks deletes every fenced code block, opened with ``` or ~~~, together with its fence lines, and leaves the surrounding prose. Inline code and indented code stay. It is handy for word counts, proofreading, translation and summaries. The removal runs in your browser, shows how many blocks were removed, and downloads as markdown-without-code-blocks.md.

Selalu Gratis Mudah digunakan Hasil seketika Pribadi dan aman

Gunakan Markdown Remove Code Blocks

Markdown: Hapus Blok Kode

Hapus blok kode Markdown yang dibatasi tag, sambil tetap menjaga agar konten di sekitarnya tetap rapi dan mudah dibaca.

Masukkan Markdown

Tempelkan Markdown yang berisi blok kode yang diapit tanda kurung
Mendukung blok yang diapit tanda kurung siku menggunakan dan``` ~~~. Kode inline seperti tidak dihapus`example`.
Belum diproses
Status pembersihan
0 dihapus
Blok kode telah dihapus

Tampilan Markdown

Markdown setelah blok kode yang diapit tanda kurung dihapus
Tips untuk melepas
Hal ini menghapus seluruh blok kode yang diapit tanda kurung kurawal dan juga mengabaikan tanda kurung kurawal yang belum selesai dengan menghapus semua yang ada setelah tanda kurung kurawal pembuka.
Tautan Alat
Telah disalin ke papan klip.
Bantu Perbaiki Alat Ini

Baca Isi

Pelajari cara kerja alat ini dan kapan harus menggunakannya.

Strip fenced code out of a Markdown document

Markdown Remove Code Blocks deletes every fenced code block from a Markdown file and leaves the surrounding prose in place. A fenced block is the kind that opens with a line of three backticks (```) or three tildes (~~~), optionally followed by a language name, and closes with a matching line. The tool removes the opening fence, everything inside, and the closing fence, then tidies the gaps so you are not left with large holes in the text.

The result is a prose-only version of a technical document: the explanations, headings, lists and links survive, while the snippets, terminal sessions, configuration listings and sample output are gone.

Why remove code from Markdown?

Code blocks are essential in documentation, but they get in the way in several common jobs:

  • Word counts and reading time. A tutorial with long listings looks far longer than its actual prose. Removing the code gives a realistic count of the words a reader has to read.
  • Proofreading and grammar checking. Spelling and style checkers flag variable names, commands and JSON keys as errors. Running them on the prose-only version cuts the noise.
  • Translation. Code must not be translated. Sending only the narrative text to a translator or translation service avoids broken snippets.
  • Summaries and AI prompts. When you want a summary of what a document says, the code often consumes most of the space. Removing it lets the explanation fit.
  • Non-technical audiences. Release notes or internal updates written for engineers can be turned into a version for managers or customers who do not need the snippets.

How the removal works

The tool runs entirely in your browser with JavaScript; nothing is sent to a server. It reads your document line by line:

  1. A line whose first non-space characters are three or more backticks or three or more tildes is treated as a fence.
  2. When the tool is not already inside a block, that fence opens one. The opening line is dropped and the block counter goes up by one.
  3. Every line after it is dropped until a closing fence of the same character type appears. The closing line is dropped too.
  4. Lines outside blocks are kept as they are.
  5. Finally, any run of three or more line breaks is reduced to a single blank line, and blank space at the start and end of the result is trimmed.

A backtick fence only closes on another backtick fence, and a tilde fence only on a tilde fence. That means a tilde block that contains a backtick example, or the other way round, is handled correctly.

The unclosed fence rule

The tip on the tool page states it plainly: unfinished code fences are handled by removing everything after the opening fence. If you forget the closing ```, the rest of the document disappears from the output. This mirrors how most renderers treat an unclosed fence (they show the rest of the file as code), but it can be surprising. If your output is much shorter than expected, look for a missing closing fence.

What is kept

ElementKept?Note
Fenced blocks with ```NoRemoved with their fences
Fenced blocks with ~~~NoRemoved with their fences
Inline code such as `example`YesThe editor hint says inline code is not removed
Indented code blocks (four spaces)YesOnly fenced blocks are detected
HTML <pre> blocksYesTreated as ordinary text
Headings, lists, links, images, tablesYesUntouched

Step-by-step

  1. Paste your document into Input Markdown, or click Paste at the top of the tool. The footer shows the character count and an estimate of possible blocks, based on the number of fence lines it can see.
  2. Click Remove Code.
  3. Check the status cards: Cleanup status reads "Output ready" when there is output, and Code blocks removed shows the exact number of blocks taken out. If nothing was found, a toast says "No code blocks found."
  4. Look over the Output Markdown editor. Its footer shows character and word counts, handy for the reading-time use case.
  5. Click Copy Output or Download. The file is saved as markdown-without-code-blocks.md.
  6. Copy Input copies your original; Clear resets the tool.

An example

Input:

## Install
Run the installer for your platform.
```bash
npm install example-cli
```
Then check the version with `example --version`.

Output:

## Install
Run the installer for your platform.
Then check the version with `example --version`.

The block and both fence lines are gone. The inline code on the last line remains, as designed.

Tips

  • Read the sentence before each removed block. Phrases like "run the following:" or "as shown below" will now point at nothing. Edit them if the prose-only version is meant to be published.
  • Compare the two counters. "possible blocks" is an estimate from counting fence lines; "Code blocks removed" is the real result. A big difference often means a stray fence line or an unclosed block.
  • Convert indented code first if needed. If your document uses four-space indented blocks and you want those gone too, change them to fenced blocks in your editor before running the tool.

A practical workflow for prose-only copies

For a tutorial you want to proofread or translate, a reliable sequence is: keep the original file untouched in your repository, paste a copy into this tool, remove the code, and work on the prose-only version. When the corrected or translated paragraphs come back, merge them into the original by hand, section by section, using the headings as anchors. The headings are never removed, so they line up between the two versions. This avoids the most common translation accident in technical writing, where a translator or tool "fixes" a command, a variable name or a JSON key inside a snippet and breaks the example for every reader.

Do not use it when

  • You need to keep the code and only want to hide it in a rendered page. This tool deletes the text; it does not fold or collapse it.
  • You want to extract the code instead of the prose. The tool keeps the opposite part of the document.
  • You want to delete only certain languages. Every fenced block is removed, regardless of its language tag.

Limitations

  • Only fenced blocks are detected. Indented code blocks and HTML pre blocks remain.
  • An unclosed fence removes everything after it.
  • Gaps are tidied by collapsing three or more line breaks into one blank line, which also affects intentional extra spacing elsewhere in the document.
  • There is no size limit in code; very large inputs depend on your browser.

Other prose clean-ups you may want next: Markdown Remove Images Keep Alt to replace pictures with their descriptions, and Markdown Links to URLs to expose link targets.

Frequently Asked Questions

Pertanyaan yang Sering Diajukan

Jawaban singkat atas pertanyaan-pertanyaan yang diajukan pengguna sebelum mempercayai hasilnya.

Fenced blocks that start and end with three or more backticks or three or more tildes, including the fence lines and any language tag.

No. Inline code in single backticks stays in the text. Only fenced blocks are removed.

A code fence was opened but never closed. The tool removes everything after an unclosed opening fence. Add the closing fence and run it again.

No. Code indented by four spaces without fences is treated as normal text and kept.

No. The removal is done by JavaScript in your browser and nothing is uploaded.

Possible blocks is a quick estimate from counting fence lines in the input. Code blocks removed is the number actually taken out after matching opening and closing fences.

The Download button saves markdown-without-code-blocks.md.

Komentar (0)

Untuk diskusi pengguna, kasus-kasus khusus, dan tips lanjutan.
Tinggalkan komentar
Komentar Anda akan ditampilkan secara publik setelah dikirim.
Belum ada komentar. Jadilah yang pertama memberikan komentar!
Beritahu Kami!
Laporkan masalah terkait alat ini

Jelaskan masalah yang Anda alami agar kami dapat menyelidikinya dan meningkatkan alat ini.

Apa yang paling membantu
Sertakan data masukan, hasil yang diharapkan, hasil yang sebenarnya, browser/perangkat, serta tangkapan layar jika diperlukan.
Tombol tangkapan layar akan mengambil gambar halaman di peramban dan melampirkan gambar yang dihasilkan ke formulir ini.
Tangkapan layar satu halaman penuh
Direkam di peramban Anda menggunakan newisty.
Belum ada tangkapan layar yang diambil.
Alat Laporan