Convert RenderCV-generated Typst (.typ) files to DOCX format
npm install rendercv-to-docx.typ) files to Microsoft Word DOCX format.
bash
Clone the repository
git clone https://github.com/anefzaoui/rendercv-to-docx.git
cd rendercv-to-docx
Install dependencies
npm install
`
Usage
$3
`bash
Basic conversion
node src/cli.js John_Doe_CV.typ
Specify output file
node src/cli.js John_Doe_CV.typ resume.docx
Verbose output
node src/cli.js John_Doe_CV.typ --verbose
Parse only (output AST as JSON)
node src/cli.js John_Doe_CV.typ --parse > ast.json
Show help
node src/cli.js --help
`
$3
`javascript
import { convertToDocx, convertFile, parse } from 'rendercv-to-docx';
import fs from 'fs';
// Convert file directly
await convertFile('John_Doe_CV.typ', 'John_Doe_CV.docx');
// Convert content string to DOCX buffer
const content = fs.readFileSync('John_Doe_CV.typ', 'utf-8');
const buffer = await convertToDocx(content);
fs.writeFileSync('resume.docx', buffer);
// Parse Typst to AST (for debugging/inspection)
const ast = parse(content);
console.log(JSON.stringify(ast, null, 2));
`
Supported RenderCV Features
$3
| Feature | Supported |
|---------|-----------|
| name | ✅ |
| headline | ✅ |
| connections (email, phone, LinkedIn, GitHub, etc.) | ✅ |
| photo | ❌ (photos not supported in DOCX output) |
$3
| Entry Type | Supported | Notes |
|------------|-----------|-------|
| ExperienceEntry | ✅ | company, position, dates, location, highlights |
| EducationEntry | ✅ | institution, degree, area, dates |
| NormalEntry | ✅ | name, dates, location, highlights |
| PublicationEntry | ✅ | title, authors, DOI, journal |
| OneLineEntry | ✅ | label: details format |
| BulletEntry | ✅ | Simple bullet points |
| TextEntry | ✅ | Plain text paragraphs |
$3
| Feature | Supported |
|---------|-----------|
| #strong[text] | ✅ Bold |
| #emph[text] | ✅ Italic |
| #link("url")[text] | ✅ Hyperlinks |
| Bullet lists (-) | ✅ |
| Headings (=, ==) | ✅ |
| Escaped characters (\/, \@, \%) | ✅ |
$3
| Feature | Supported |
|---------|-----------|
| Colors (name, sections, links, body) | ✅ |
| Font families | ✅ |
| Font sizes | Partial (uses sensible defaults) |
| Page margins | ❌ (uses Word defaults) |
| Section title styles | ✅ (underlined headings) |
Example
Input (RenderCV Typst file):
`typst
#import "@preview/rendercv:0.1.0": *
#show: rendercv.with(
name: "Jane Doe",
colors-name: rgb(0, 79, 144),
colors-section-titles: rgb(0, 79, 144),
)
= Jane Doe
#headline([Senior Software Engineer | Full-Stack Developer])
#connections(
[#connection-with-icon("location-dot")[San Francisco, CA]],
[#link("mailto:jane@example.com")[jane\@example.com]],
)
== Experience
#regular-entry(
[
#strong[Acme Corp], Senior Engineer
- Led migration to microservices architecture
- Reduced deployment time by 80%
],
[
San Francisco, CA
Jan 2020 – present
],
)
`
Output: A properly formatted DOCX file with:
- Colored name and section headers
- Clickable email/phone links
- Properly structured experience entries with bullet points
- Professional typography
API Reference
$3
Convert Typst content string to DOCX buffer.
- content string - Typst file content
- options object - Optional conversion settings
- Returns: Promise - DOCX file buffer
$3
Convert Typst file to DOCX file.
- inputPath string - Path to input .typ file
- outputPath string - Path to output .docx file
- options object - Optional conversion settings
- Returns: Promise<{inputPath, outputPath, success}>
$3
Parse Typst content and return AST.
- content string - Typst file content
- Returns: object - Parsed AST
$3
Generate DOCX from parsed AST.
- ast object - Parsed Typst AST
- options object - Generation options
- Returns: Promise - DOCX file buffer
Limitations
This tool is specifically designed for RenderCV output. It does NOT support:
- ❌ Generic Typst documents
- ❌ Custom Typst functions/macros
- ❌ Typst scripting (loops, conditionals, variables)
- ❌ Math equations
- ❌ Tables
- ❌ Images/photos
- ❌ Multi-column layouts
- ❌ Custom fonts (uses system fonts)
If you need a generic Typst → DOCX converter, you would need to essentially reimplement the Typst compiler, which is a massive undertaking.
How It Works
1. Parse - Reads the Typst file and extracts:
- Metadata from rendercv.with() configuration
- Header info (name, headline, connections)
- Sections and their entries
- Inline formatting
2. Transform - Converts the parsed AST to docx library structures:
- Maps RenderCV entry types to Word paragraphs
- Applies colors from metadata
- Creates hyperlinks for connections
- Formats bullet points and highlights
3. Generate - Uses the docx library to produce the final DOCX file
Development
`bash
Run tests
npm test
Convert sample file
npm run convert
Debug parsing
node src/cli.js sample.typ --parse | jq .
``