Overview Version History Q & A Rating & Review
Code to Markdown (Code2Markdown) Extension for Visual Studio Code
The Code2Markdown Extension lets you convert selected code files in VS Code into a single Markdown file. Each file's content is wrapped in a syntax-highlighted code block, making it ideal for documentation, sharing, or archiving code snippets. It's especially useful for preparing code in an AI-friendly format for prompts.
Why use Code2Markdown?
Benefits for AI Prompts
Efficient Token Usage : Markdown's lightweight syntax minimizes token counts, reducing costs with AI services.
Easy for AI to Understand : Plain-text format with language identifiers (e.g., ```python) helps AI parse code accurately.
Organized and Readable : Structure your codebase with headers and sections for clarity.
Faster Processing : Markdown requires no preprocessing, speeding up AI response times.
How Code2Markdown Saves Time and Money
One-Click Markdown Creation : Automatically formats code into Markdown with proper code blocks.
Token Optimization : Clean output reduces token usage, lowering costs.
Reduced Processing Time : Structured Markdown helps AI understand your code faster.
Cost Savings : Lower token counts and quicker interactions save money for programmers using AI services.
Features
Generate Markdown files from multiple files via the Command Palette or Explorer context menu.
Table of Contents : Automatically generates a TOC with links to each included file.
Unique file naming with timestamps and versioning to prevent overwrites.
Syntax highlighting based on file extensions (e.g., .ts
→ typescript
, .py
→ python
, .rs
→ rust
).
Display of relative file paths for better context.
Detailed logging for troubleshooting.
Installation from VS Code
You can install the Code2Markdown Extension directly from the VS Code Marketplace within VS Code:
Open VS Code.
Click the Extensions icon in the Activity Bar or press Ctrl+Shift+X
(Windows/Linux) or Cmd+Shift+X
(macOS).
Search for Code2Markdown
.
Look for "Code2Markdown Extension" by WIZWAM.
Click Install .
Alternatively, you can install it via the VS Code Quick Open command:
Open Quick Open with Ctrl+P
(Windows/Linux) or Cmd+P
(macOS).
Paste the following command and press Enter:
ext install WIZWAM.Code2Markdown-Wizwam
Installation from GitHub Repository
To install and test the extension directly from the GitHub repository, follow these steps:
Clone the Repository :
Install Dependencies :
Open a terminal in the code2md
directory.
Run the following command to install the required dependencies:
npm install
Compile the Extension :
Compile the TypeScript code into JavaScript:
npm run compile
Alternatively, use npm run watch
to automatically recompile on changes.
Test the Extension in VS Code :
Open the code2md
folder in VS Code.
Press F5
to launch a new VS Code window with the extension loaded.
Use the Command Palette or context menu to test Markdown generation.
Usage
Using the Command Palette
Open the Command Palette (Ctrl+Shift+P
on Windows/Linux, Cmd+Shift+P
on macOS).
Type Generate Markdown from Files
and select it.
Choose one or more files in the file picker.
A Markdown file (e.g., 2023-10-25_0230PM_MyProject_v01.md
) will be created in the codereview
folder.
Using Folder Selection (Recommended for Multiple Files)
Open the Command Palette (Ctrl+Shift+P
on Windows/Linux, Cmd+Shift+P
on macOS).
Type Generate Markdown from Folder
and select it.
Choose a folder containing the files you want to include.
Note : Select the folder itself, not individual files within it.
Enter the file extensions to include (e.g., rs,toml,html
).
The extension will recursively find all matching files and generate a Markdown file in the codereview
folder.
In the Explorer, select one or more files using Ctrl+Click
(Windows/Linux) or Cmd+Click
(macOS) for multiple selections.
Right-click and choose Generate Markdown from Selected Files
.
A Markdown file with a Table of Contents and all selected files will be generated in the codereview
folder:
your-project/
└── codereview/
├── 2025-03-19_0257PM_MyProject_v01.md # Generated markdown file
└── 2025-03-19_0257PM_MyProject_v01.log # Corresponding log file
Note : If multiple file selection doesn't work, use the "Generate Markdown from Folder" command instead.
The generated Markdown includes:
Troubleshooting
Log Files : Check detailed logs in the codereview
folder (e.g., codereview/2025-03-19_0257PM_MyProject_v01.log
).
Output Location : All generated files are stored in a codereview
folder in your workspace.
Output Panel : Open the Output panel in VS Code (Ctrl+Shift+U
), select "Extension Host," and look for [code2md]
messages.
Common Issues :
No files selected : Ensure you select files or a folder as required by the command.
Multiple file selection issues : Use the "Generate Markdown from Folder" command if Ctrl+Click
fails.
Permission errors : Verify VS Code has write access to create and write to the codereview
directory.
Development
License
This project is licensed under the MIT License - see the LICENSE file for details.