Get the code out of an AI answer
Paste the whole answer, explanation included: out come separate files, with the name the model gave them and the right extension, one by one or all in one .zip. And the mangled characters that stop the code from running are found and fixed. Nothing leaves your browser.
You can also drag a text file here.
Why AI code sometimes will not run
The model writes curly quotes instead of straight ones, long dashes instead of the double minus of command options, and now and then it slips a non-breaking space into the indentation or a zero-width character into the middle of a word. In prose those are typographic details; in code the program does not run, and the error never says «you have a curly quote on line 12»: it says something baffling about the wrong place. Here they are counted by kind and fixed, and it says how many and which.
Two switches, because the two cases are not the same
The invisible ones (non-breaking space, zero width, soft hyphen) are never legitimate in code: they only break things, so they are fixed by default. Curly quotes and long dashes, on the other hand, can be there on purpose inside a text string: if your program prints a sentence with typographic quotes, replacing them would be damage. That is why they are a separate switch, off, with the count in front of you so you can decide.
The file name, not «code1.txt»
The model nearly always says the name: on the line before the block («src/app.js») or as a comment on the first line («// src/app.js»). It is read from there. Where there is none, the language written next to the backticks is used, and when that is missing too it is worked out from the content (a shebang, a <?php, a def, some JSON) so at least the extension is right. And two files can never end up with the same name inside the .zip.
When the answer is cut off, it says so
If a block is never closed it means the chat stopped halfway, and handing over half a file without saying anything is the best way to waste an hour of someone's time: the block is still shown, but flagged. And blocks of terminal commands are not files to save, so they are called what they are, with an extra line if there is a sudo, an rm -rf or a download piped straight into a shell inside: it is not an alarm, it is the fact, written before you paste it.
What it does not do
It runs nothing and checks nothing: it cuts out, names and fixes characters, that is all. The text of every block is an exact piece of what you pasted until you turn on one of the two fixes. If what you need from the answer is the prose without the markdown asterisks, there is Strip markdown and invisible characters; to see what it changed in a text there is What the AI changed.