Code Syntax Highlighter (Copy Code to Word & Docs)
Coloured code for Word, Google Docs, slides, e-mail and blogs, in more than 240 languages.
Try before you buy.
- Free preview: your code highlighted with every option you choose, drawn as a marked picture up to 900 pixels wide.
- Locked until you unlock it: download and copy.
- Unlock: Pro pass, ₹179 for 30 days or ₹79 for 1 week, a one-time payment that never renews. Unlock: Pro pass, $5.99 for 30 days or $2.99 for 1 week, a one-time payment that never renews.
Ways to unlock shows how to get the full result.
Printing this result is locked in the free preview.
Your code
Font, background and lines
The shown line numbers, single or as ranges.
Highlighted
“Copy for Word, Docs and slides” puts the coloured code on the clipboard as rich text: paste it into Word, Google Docs, PowerPoint, Keynote, Outlook or Gmail. “Copy HTML” has the colours inline, for a blog or a CMS’s HTML block; “Copy HTML + CSS” uses classes and a stylesheet. Ctrl+Enter (⌘+Enter) in the code box copies for documents.
Locked in the free preview. Opens the ways to unlock this result.
Locked in the free preview. Batch runs unlock with a pass.
Locked in the free preview. Query results unlock with a pass.
About the Code Syntax Highlighter (Copy Code to Word & Docs)
Paste code and get it back highlighted the way your editor shows it, ready to paste into a document, a slide, an e-mail or a web page. The highlighting comes from Shiki, which uses the TextMate grammars and the colour themes of Visual Studio Code: more than 240 languages and 65 themes, light and dark. The language can be guessed for you by highlight.js’s detector.
Choose the font and its size, the line height, the background (the theme’s, none or your own colour), padding and rounded corners, the tab width, line numbers that start where your file does, highlighted lines, and added and removed lines for a diff. With a pass, Copy for Word, Docs and slides puts the result on the clipboard as rich text that keeps its colours when you paste it into Word, Google Docs, PowerPoint, Keynote, Outlook or Gmail; Copy HTML gives a code block with inline styles for a blog or a CMS, Copy HTML + CSS one with classes and a stylesheet, and the HTML, RTF and SVG files take the same block elsewhere.
Everything runs in your browser; the code is never uploaded. Without a pass the result is a free preview: the highlighted code is drawn as a picture with a MySmartCoPilot mark, and copying it and the files unlock with a Pro pass. For a picture of code to post, use the Code Screenshot Generator.
How to use it
- Paste your code into Your code, open a source file, or press Example. With Detect automatically the language is guessed from the code; pick it from the list when the guess is wrong.
- Choose a Theme. Light themes suit white documents; a dark theme needs its own background, so keep Theme’s background for it.
- Under Font, background and lines, set the font, size, line height, padding and corners; turn on Line numbers (and the first line’s number), type the lines to highlight such as
3, 5-7, or mark a diff’s + and − lines as added and removed. - With a pass, press Copy for Word, Docs and slides and paste where you need it, use Copy HTML or Copy HTML + CSS for a web page, or download the HTML, RTF or SVG file; without a pass the free preview shows the result as a marked picture.
Examples
Language: TypeScript · Theme: GitHub Light · Font: Consolas 14 px · Line numbers on, first line 42 · Highlight lines: 44-45
Pasted into Word: the code in its colours with its indentation, numbered from 42, lines 44 and 45 on a shaded band, in Consolas at 10.5 pt (14 px).
- if (user.role === "admin") {
+ if (user.permissions.includes("billing:write")) {
showBilling();
}With “Lines starting with + and − are added and removed lines” on, the new line sits on green and the old one on red. Untick “Keep the + and − signs” and the code is highlighted as JavaScript without them.
Language: Python · Theme: One Dark Pro · Copy HTML
<pre style="…;background-color:#282c34;color:#abb2bf;…"><code><span style="display:block"><span style="color:#c678dd">def</span> …
Paste it into an HTML block (WordPress’s Custom HTML, Ghost’s HTML card): every colour is inline, so the theme of the site does not change it.
Common uses
- Putting code into a report, a thesis, a specification or a contract annex written in Word or Google Docs.
- Code on slides in PowerPoint, Keynote or Google Slides that stays text you can edit, not a picture.
- Coloured snippets in e-mail and newsletters, where external stylesheets do not work.
- Code blocks for a blog or a CMS without installing a highlighting plugin.
Which output to use
- Copy for Word, Docs and slides: rich text with every colour inline, the font and its size, the background and the line marks. Apps that accept formatted text keep it; if one pastes the text in its own style, use its “Keep source formatting” paste option.
- Copy HTML: a
<pre><code>block with inline styles. Use it where you can paste HTML: a CMS’s HTML block, a static site, an e-mail template. - Copy HTML + CSS: the same block with short class names (
csh-…) and the stylesheet that colours them, for a site that keeps its CSS in one place. The HTML file is a small page with both. - RTF: a document for Word, WordPad, TextEdit, LibreOffice or Pages, and for any app whose paste drops the colours.
- SVG: a vector image with the code as real text, for design tools and slides; it uses the fonts of the computer that opens it.
Fonts and sizes
The copies name the font you choose followed by fallbacks that end in the generic monospace font, so a reader who does not have it still gets a monospaced font. Consolas and Courier New are on most Windows and Office installations; Menlo is on every Mac. Sizes are in pixels; documents use points, at 0.75 points a pixel (14 px is 10.5 pt). Tabs become spaces at the width you choose, so the alignment is the same everywhere.
Limitations
- Up to 5,000 lines or 400,000 characters at a time.
- The language detector chooses among about 35 common languages; for any other, pick the language yourself.
- Lines longer than 20,000 characters (minified code) are shown in one colour.
- The coloured copy needs a browser that can put rich text on the clipboard, as current Chrome, Edge, Safari and Firefox do; elsewhere it copies plain text, and the RTF file keeps the colours.
- Each language and theme is downloaded the first time you use it, so a new one needs a connection.
Privacy
On this device; its files download once
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot. The highlighter (Shiki, with a WebAssembly regular-expression engine of about 470 KB) is downloaded from this site the first time you highlight, and each language grammar and theme the first time you pick it; your code is never uploaded.
Frequently asked questions
What do I get without a pass?
Without a pass, Code Syntax Highlighter (Copy Code to Word & Docs) shows your code highlighted with every option you choose, drawn as a marked picture up to 900 pixels wide. Until you unlock it, the result can’t be downloaded or copied. A Pro, Premium or Ultimate pass, a one-time payment that never renews, unlocks the full result. The pricing page lists the passes and their prices.
Is my code uploaded?
No. Highlighting and every export happen in your browser; only the highlighter, the grammars and the themes are downloaded from this site.
Why are the colours gone after I paste?
The app pasted plain text. Paste with the normal paste command (not “Paste as plain text”, often Ctrl+Shift+V), or pick the app’s “Keep source formatting” option. Where an app never keeps formatting, open the RTF file in it instead.
Which theme should I use for a printed or white document?
A light theme such as GitHub Light, Light Plus, Solarized Light or One Light, with the theme’s background or none. Dark themes are made for a dark background: without it their light text is hard to read on white, and the page says so.
Can I show a diff and highlight lines at the same time?
Yes. Added and removed lines take their green and red bands; the lines you list under Highlight lines take the theme’s highlight colour unless they are part of the diff.
Will the line numbers be copied too?
In the rich copy and the RTF file they are part of the text, as they are in a printed listing. In the HTML copies they are marked so that a reader who selects and copies the code from your page gets the code without them.