Code Block Extractor & RemoverMarkdown, ChatGPT, Claude

Paste an AI reply and get its code blocks as a list, ready to copy. Switch modes to delete the code and keep only the explanation.

Your input is never sent anywhere.

Details
Paste AI Output
1 line
1

Results

Code blocks

0

Characters

0

Detected Code Blocks

No fenced code blocks found.

TIP

If the reply has several code blocks, compare their line counts in the list to find the one you need.

Copy Code From a ChatGPT or Claude Reply Without the Backticks

When you ask ChatGPT, Claude, or another chatbot for code, the reply mixes explanation with fenced code blocks, the parts wrapped in triple backticks. Copying only the code usually means scrolling, selecting by hand, and deleting stray fence lines.

Going the other way is just as common. You want the explanation for notes or documentation, and the code is in the way. Editing a long reply with several blocks by hand makes it easy to miss one.

Paste the reply here. The tool finds every fenced block, lists it with its language and line count, and lets you copy one block or all of them. Switch modes to delete the code and keep the text.

Typical Uses for Splitting Code From Explanation

Pasting one script into your editor

A reply has three blocks and you need only the second. Pick it from the list and copy it, with no fence lines or surrounding text.

Saving the explanation for notes

Keep the explanation for a wiki page or ticket while the code lives in your repo. Text mode removes the blocks and can leave a marker where each one was.

Sorting a mixed-language answer

A setup guide with bash, Python, and SQL blocks shows each language as a tag, so you can see what the reply contains before you copy anything.

Checking for a cut-off reply

If the last block never closes, the tool flags it and treats everything to the end of the text as part of that block, so you can see where the reply stopped.

How to Pull Out or Strip Fenced Code in 4 Steps

  1. Paste the AI reply into the input box, or click Load Sample to try it.
  2. Choose Extract Code or Keep Text Only.
  3. In Extract Code, select a block in the list to preview it, then click Copy. Use Copy All Blocks to get every block at once.
  4. In Keep Text Only, choose whether to leave a marker and how to treat inline code, then copy or download the text.

Note: Everything runs in your browser. The tool has no upload step.

What Counts as a Code Block

  • A fence is a line that starts with three or more backticks or tildes, optionally indented. A language label after it, such as python, is shown as a tag.
  • A block closes at a line containing only the same character, repeated at least as many times as the opening line. A four-backtick block can therefore contain triple-backtick lines.
  • A fence that never closes runs to the end of your text. It is marked as unclosed in the list and in the warning.
  • In Keep Text Only, removed blocks can leave a marker like [Code block removed: bash]. Runs of three or more blank lines are reduced to one blank line.
  • Inline code means text between single backticks on one line. Spans written with double backticks may leave stray backticks behind.
  • Downloads use the block's language label for the file extension (for example .py or .sh) and fall back to .txt.

Extract Code or Keep Text: Which Mode to Use

A quick guide to matching the mode to what you need.

Your goalModeWhat you get
Paste AI-written code into an editorExtract CodeEach block copies on its own, or all blocks together with optional headers
Find one block in a multi-language replyExtract CodeEach block shows a language tag and a line count
Move the explanation into docs or notesKeep Text OnlyFenced blocks are removed, with an optional marker in their place
Clean up inline `variable` names in a paragraphKeep Text OnlyDrop just the backticks, or delete the whole word

Handling Triple Backticks in AI Output

Short notes on why these fences show up and how to deal with them.

Why chat replies include triple backticks

Chat tools write replies in Markdown, where triple backticks fence off code. The chat window draws them as a box, but copying the raw text brings the fence lines along, and they usually cause errors when pasted into an editor or config file.

List the blocks before you copy

When a reply has bash commands followed by a Python script, selecting by hand is easy to get wrong. Seeing every block with its language and line count first makes it simpler to pick the right one.

A missing closing fence often means a cut-off reply

If the final block has no closing fence, the reply may have been cut short or your copy may have missed the end. Check any unclosed block before you run it.

Inline code: unwrap or delete

Unwrapping turns `read_csv` into read_csv, which usually reads fine in a paragraph. Deleting removes the word too and can leave a gap in the sentence, so use it only when the term isn't needed.

Common Copy-Paste Mistakes With AI Code

Deleting fence lines by hand and clipping the code

While removing the opening and closing fence lines manually, you also delete the first or last line of the code, and the script fails.

💡 See the solution▼
Copy the block from the list instead. The fence lines are not included in the copied text.

Copying an outdated version of a rewritten file

When the AI rewrites the same file several times in one reply, it's easy to paste an earlier version.

💡 See the solution▼
Check the preview and line count of each block before copying. Later blocks are often the newer revisions, but confirm it.

Pasting code into your notes along with the explanation

Copying the whole reply into a document leaves code and prose mixed together, which is hard to read later.

💡 See the solution▼
Use Keep Text Only to remove the blocks first, then paste the text. Leave the marker on if you want to see where code was removed.

Running code from a truncated reply

Part of the reply is missing from your copy, the closing fence is gone, and the code fails with a syntax error you then have to trace.

💡 See the solution▼
Look for the unclosed warning in the results panel before you run anything.

FAQ: Fences, Inline Code, and Privacy

Q.How do I extract code from a ChatGPT or Claude response?

Q.

A. Paste the full reply into the input box. The tool finds every fenced code block (the parts wrapped in triple backticks or triple tildes) and lists each one with its language and line count. Select a block to preview it, then click Copy. Copy All Blocks combines every block into one clipboard entry, with an optional header line before each.

Q.Can I remove the code and keep only the explanation?

Q.

A. Yes. Switch to Keep Text Only. Fenced blocks are deleted from the output, and you can choose to leave a marker such as [Code block removed: python] where each one was. Runs of three or more blank lines are reduced to one blank line so the text reads cleanly.

Q.What happens to inline code like `variable_name`?

Q.

A. In Keep Text Only mode you can turn inline code handling on or off. When it is on, you choose between removing just the backticks (the word stays) or deleting the whole word. Only single-backtick spans on one line are matched, so a span written with double backticks may leave stray backticks behind.

Q.What if a code block is missing its closing fence?

Q.

A. The tool treats everything from the opening fence to the end of your text as one block, marks it as unclosed in the list, and shows a warning. This usually means the reply was cut off or the copy missed the end, so check the code before you run it.

Q.Does it work with ~~~ fences or four backticks?

Q.

A. Yes. A fence can use three or more backticks or tildes. A block closes at a line that contains only the same character, repeated at least as many times as the opening fence. This lets a four-backtick block contain triple-backtick lines without ending early.

Q.Is my text uploaded anywhere?

Q.

A. No. Parsing and extraction run as JavaScript in your browser, and the tool has no upload step. Copy and download both use your own device.

Q.What file names do downloads use?

Q.

A. A single block downloads as code-block-N with an extension based on its language label, for example .py for python or .sh for bash. Unknown or missing labels use .txt. All blocks together download as extracted-code.txt, and the text-only output downloads as extracted-text.txt.

User Feedback & Request

Your feedback
makes this tool better.

Tell us which features you'd like, what should be fixed, or which new tool you'd like to see. An engineer reads every submission and uses it to guide development.

Send feedback