Skip to main content
Convert documents between formats using SuperDoc’s high-fidelity conversion engine.

Usage

import Casedev from 'casedev';

const client = new Casedev({ apiKey: 'sk_case_YOUR_API_KEY' });

// Using file upload
const pdf = await client.superdoc.v1.convert({
  file: documentFile,
  from: 'docx',
  to: 'pdf'
});

// Using base64
const docx = await client.superdoc.v1.convert({
  document_base64: Buffer.from(markdownContent).toString('base64'),
  from: 'md',
  to: 'docx'
});

// Using URL
const result = await client.superdoc.v1.convert({
  document_url: 'https://example.com/document.docx',
  from: 'docx',
  to: 'pdf'
});

Parameters

ParameterTypeRequiredDescription
fileFileOne ofDocument file (multipart upload)
document_urlstringOne ofURL to fetch document from
document_base64stringOne ofBase64-encoded document content
fromstringYesSource format: docx, md, html
tostringNoTarget format: pdf, docx. Default: pdf

Supported conversions

FromToNotes
docxpdfFull fidelity conversion
mddocxConverts Markdown to Word
mdpdfMarkdown to PDF (via DOCX)
htmldocxHTML content to Word

Response

Returns the converted document as binary data with appropriate content type:
  • application/pdf for PDF output
  • application/vnd.openxmlformats-officedocument.wordprocessingml.document for DOCX output

Examples

Convert uploaded file

// Express/Next.js file upload handler
export async function POST(request: Request) {
  const formData = await request.formData();
  const file = formData.get('file') as File;

  const pdf = await client.superdoc.v1.convert({
    file: file,
    from: 'docx',
    to: 'pdf'
  });

  return new Response(pdf, {
    headers: {
      'Content-Type': 'application/pdf',
      'Content-Disposition': 'attachment; filename="converted.pdf"'
    }
  });
}

Generate Word doc from Markdown

const markdown = `
# Quarterly Report

## Executive Summary
Revenue increased by 15% compared to Q3...

## Key Metrics
| Metric | Value |
|--------|-------|
| Revenue | $1.2M |
| Growth | 15% |
`;

const docx = await client.superdoc.v1.convert({
  document_base64: Buffer.from(markdown).toString('base64'),
  from: 'md',
  to: 'docx'
});

fs.writeFileSync('report.docx', docx);

Limits

LimitValue
Max file size25 MB
Concurrent requests10 per API key