> ## Documentation Index
> Fetch the complete documentation index at: https://slatehq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Convert to HTML/Markdown

> Convert between HTML and Markdown formats for content processing and formatting.

## What is the Convert to HTML/Markdown Block?

The Convert to HTML/Markdown block transforms content between HTML and Markdown formats. Use it to convert web content for display, prepare content for publishing, or process scraped data into readable formats.

**Common use cases:**

* Convert Markdown content to HTML for web publishing
* Transform HTML from web scraping into clean Markdown
* Format LLM-generated Markdown for email or web display
* Clean up HTML content by converting to Markdown and back
* Prepare content for different platforms (CMS, email, documentation)
* Extract readable text from HTML pages
* Format structured content for Google Sheets

***

## How Does the Convert to HTML/Markdown Block Work?

1. **Provide content** - Enter HTML or Markdown content (or reference previous steps)
2. **Select conversion direction** - Choose to convert to HTML or Markdown
3. **Block processes** - Converts content to the selected format
4. **Returns converted output** - Clean HTML or Markdown ready to use

***

## Configuration

### Content (Required)

Enter the HTML or Markdown content you want to convert.

**Static content:**

```markdown theme={null}
# Welcome to Our Platform

Learn how to use **workflows** to automate tasks.
```

**Reference previous steps:**

```liquid theme={null}
{{step_3.output}}
```

**Use Liquid templating:**

```liquid theme={null}
{{step_1.output.content}}

Generated for: {{step_2.output.Keyword}}
```

Click the `{ }` icon to insert placeholders from previous steps or inputs.

***

### Convert to

Select the output format.

**Options:**

1. **HTML**: Converts Markdown to HTML
   * Use when: Publishing to web, sending HTML emails, formatting for CMS

2. **Markdown**: Converts HTML to Markdown
   * Use when: Cleaning scraped content, making HTML readable, preparing for text processing

***

## Error Handling

Define what happens if the conversion fails.

**Options:**

1. **Terminate workflow**: Stop execution immediately
2. **Continue execution**: Proceed to next step with empty output

**Retry** isn't available for this block.

Select based on whether subsequent steps require the converted content.

***

## Use Cases and Examples

### Use Case 1: Convert Markdown to HTML for Web Publishing

**Scenario:** Convert LLM-generated Markdown content to HTML for a blog post

**Configuration:**

* **Content**: `{{step_3.output}}`
* **Convert to**: HTML

**Input (Markdown):**

```markdown theme={null}
# The Ultimate Guide to CRM Software

## What is CRM Software?

CRM (Customer Relationship Management) software helps businesses manage:

- Customer interactions
- Sales pipelines
- Marketing campaigns

**Key benefits:**
1. Improved customer relationships
2. Increased sales efficiency
3. Better data organization

[Learn more](https://example.com/crm)
```

**Output (HTML):**

```html theme={null}
<h1>The Ultimate Guide to CRM Software</h1>

<h2>What is CRM Software?</h2>

<p>CRM (Customer Relationship Management) software helps businesses manage:</p>

<ul>
<li>Customer interactions</li>
<li>Sales pipelines</li>
<li>Marketing campaigns</li>
</ul>

<p><strong>Key benefits:</strong></p>

<ol>
<li>Improved customer relationships</li>
<li>Increased sales efficiency</li>
<li>Better data organization</li>
</ol>

<p><a href="https://example.com/crm">Learn more</a></p>
```

***

### Use Case 2: Convert HTML to Markdown for Readability

**Scenario:** Clean up web-scraped HTML content into readable Markdown

**Configuration:**

* **Content**: `{{step_2.output}}`
* **Convert to**: Markdown

**Input (HTML):**

```html theme={null}
<div class="article">
  <h1>5 Best Marketing Automation Tools</h1>
  <p>Marketing automation helps businesses <strong>scale their efforts</strong> efficiently.</p>
  <h2>Top Tools:</h2>
  <ul>
    <li><a href="https://hubspot.com">HubSpot</a> - All-in-one platform</li>
    <li><a href="https://marketo.com">Marketo</a> - Enterprise solution</li>
    <li><a href="https://mailchimp.com">Mailchimp</a> - Email focused</li>
  </ul>
</div>
```

**Output (Markdown):**

```markdown theme={null}
# 5 Best Marketing Automation Tools

Marketing automation helps businesses **scale their efforts** efficiently.

## Top Tools:

* [HubSpot](https://hubspot.com) - All-in-one platform
* [Marketo](https://marketo.com) - Enterprise solution
* [Mailchimp](https://mailchimp.com) - Email focused
```

***

### Use Case 3: Format Content for Email

**Scenario:** Convert Markdown report to HTML for email sending

**Configuration:**

* **Content**: Template with Liquid syntax
* **Convert to**: HTML

**Input (Markdown with Liquid):**

```liquid theme={null}
# Weekly Keyword Report

Target Keyword: **{{step_1.output.Keyword}}**

## Metrics
- Search Volume: {{step_1.output.Search_Volume}}
- Difficulty: {{step_1.output.Keyword_Difficulty_Index}}/100

{% if step_1.output.Keyword_Difficulty_Index > 70 %}
**Status**: High difficulty - requires strategic approach
{% else %}
**Status**: Moderate opportunity
{% endif %}

---
*Report generated automatically*
```

**Output (HTML):**

```html theme={null}
<h1>Weekly Keyword Report</h1>

<p>Target Keyword: <strong>crm software</strong></p>

<h2>Metrics</h2>

<ul>
<li>Search Volume: 74000</li>
<li>Difficulty: 76/100</li>
</ul>

<p><strong>Status</strong>: High difficulty - requires strategic approach</p>

<hr />

<p><em>Report generated automatically</em></p>
```

***

### Use Case 4: Extract Clean Text from Scraped HTML

**Scenario:** Convert complex HTML from web scraping to clean Markdown

**Configuration:**

* **Content**: `{{step_5.output}}`
* **Convert to**: Markdown

**Input (Complex HTML):**

```html theme={null}
<article class="content-wrapper">
  <div class="header">
    <h1 class="title">Understanding SEO in 2024</h1>
  </div>
  <div class="body">
    <p class="intro">Search engine optimization continues to evolve with <em>AI-powered</em> search.</p>
    <div class="section">
      <h2>Key Trends</h2>
      <ol class="trend-list">
        <li><strong>AI Content</strong>: Quality over quantity</li>
        <li><strong>User Experience</strong>: Core Web Vitals matter</li>
        <li><strong>E-E-A-T</strong>: Expertise and trust signals</li>
      </ol>
    </div>
  </div>
</article>
```

**Output (Clean Markdown):**

```markdown theme={null}
# Understanding SEO in 2024

Search engine optimization continues to evolve with _AI-powered_ search.

## Key Trends

1. **AI Content**: Quality over quantity
2. **User Experience**: Core Web Vitals matter
3. **E-E-A-T**: Expertise and trust signals
```

***

### Use Case 5: Prepare Markdown for CMS

**Scenario:** Convert Markdown content to HTML for WordPress or other CMS

**Configuration:**

* **Content**: Combined content from multiple steps
* **Convert to**: HTML

**Input (Markdown):**

```liquid theme={null}
## {{step_1.output.Keyword | capitalize}}

{{step_3.output}}

### Related Topics
{% for kw in step_2.output limit:5 %}
- [{{kw.Keyword}}](#)
{% endfor %}
```

**After Liquid Processing:**

```markdown theme={null}
## Crm Software

Comprehensive guide to choosing the right CRM for your business...

### Related Topics
- [sales automation](#)
- [customer management](#)
- [crm tools](#)
- [business software](#)
- [sales pipeline](#)
```

**Output (HTML):**

```html theme={null}
<h2>Crm Software</h2>

<p>Comprehensive guide to choosing the right CRM for your business...</p>

<h3>Related Topics</h3>

<ul>
<li><a href="#">sales automation</a></li>
<li><a href="#">customer management</a></li>
<li><a href="#">crm tools</a></li>
<li><a href="#">business software</a></li>
<li><a href="#">sales pipeline</a></li>
</ul>
```

***

### Use Case 6: Clean HTML Tables to Markdown

**Scenario:** Convert HTML table data to Markdown format

**Configuration:**

* **Content**: `{{step_1.output}}`
* **Convert to**: Markdown

**Input (HTML):**

```html theme={null}
<table>
  <tr>
    <th>Keyword</th>
    <th>Volume</th>
    <th>Status</th>
  </tr>
  <tr>
    <td>crm software</td>
    <td>74000</td>
    <td>High Priority</td>
  </tr>
  <tr>
    <td>sales tools</td>
    <td>33100</td>
    <td>Medium Priority</td>
  </tr>
</table>
```

**Output (Markdown):**

```markdown theme={null}
Keyword | Volume | Status
--- | --- | ---
crm software | 74000 | High Priority
sales tools | 33100 | Medium Priority
```

***

### Use Case 7: Format Documentation

**Scenario:** Convert Markdown documentation to HTML for knowledge base

**Configuration:**

* **Content**: Static Markdown with formatting
* **Convert to**: HTML

**Input (Markdown):**

```markdown theme={null}
## Installation Guide

Follow these steps:

1. **Download** the software
2. **Install** dependencies
   - Node.js 18+
   - Python 3.9+
3. **Run** `npm install`

> **Note:** Make sure you have admin privileges

For support, contact [support@example.com](mailto:support@example.com)
```

**Output (HTML):**

```html theme={null}
<h2>Installation Guide</h2>

<p>Follow these steps:</p>

<ol>
<li><strong>Download</strong> the software</li>
<li><strong>Install</strong> dependencies
<ul>
<li>Node.js 18+</li>
<li>Python 3.9+</li>
</ul></li>
<li><strong>Run</strong> <code>npm install</code></li>
</ol>

<blockquote>
<p><strong>Note:</strong> Make sure you have admin privileges</p>
</blockquote>

<p>For support, contact <a href="mailto:support@example.com">support@example.com</a></p>
```

***

## Best Practices

### Converting to HTML

* **Use for publishing**: Convert Markdown to HTML when content goes to web, email, or CMS
* **Preserve formatting**: Markdown supports headers, lists, links, emphasis, code blocks, tables
* **Check output**: HTML includes proper tags (`<h1>`, `<p>`, `<ul>`, `<a>`, etc.)
* **Combine with APIs**: Use HTML output for API calls or webhook payloads

### Converting to Markdown

* **Clean scraped content**: HTML to Markdown removes styling and classes
* **Improve readability**: Markdown is cleaner for storage and processing
* **Prepare for LLMs**: Many LLMs work better with Markdown format
* **Save to sheets**: Markdown is more readable in Google Sheets than HTML

### Content Handling

* **Test conversions**: Run workflow to verify output format
* **Use Liquid carefully**: Template syntax processes before conversion
* **Handle special characters**: Markdown uses `*`, `_`, `#` - escape if needed in HTML
* **Preserve links**: Both directions maintain links properly

### Common Patterns

**Markdown to HTML for email:**

```liquid theme={null}
# Weekly Report

Target: {{step_1.output.Keyword}}
Volume: {{step_1.output.Search_Volume}}
```

→ Converts to clean HTML email

**HTML to Markdown for processing:**

```liquid theme={null}
{{step_2.output}}
```

→ Clean Markdown for further LLM processing

**Combined content:**

```liquid theme={null}
## Analysis for {{step_1.output.Keyword}}

{{step_3.output}}

### Data
| Metric | Value |
|--------|-------|
| Volume | {{step_1.output.Search_Volume}} |
| Difficulty | {{step_1.output.Keyword_Difficulty_Index}} |
```

***

## Troubleshooting

### Conversion Output Not as Expected

**Problem:** HTML/Markdown output doesn't look right.

**Solution:**

* Check input format is valid HTML or Markdown
* Test with simple content first
* Verify Liquid placeholders resolve correctly
* Use Text block to inspect input before conversion

***

### Liquid Variables Not Rendering

**Problem:** Output shows `{{step_1.output}}` instead of actual data.

**Solution:**

* Verify step number is correct
* Ensure previous step completed successfully
* Check step has output data
* Test reference in Text block first

***

### Special Characters Breaking Format

**Problem:** Characters like `*`, `_`, `#` cause issues.

**Solution:**

* When converting to Markdown: These are Markdown syntax
* When converting to HTML: Escape special HTML chars if needed
* Use Code block for complex escaping if required

***

### Tables Not Converting Properly

**Problem:** HTML tables to Markdown or vice versa don't format correctly.

**Solution:**

* Ensure HTML tables use proper `<table>`, `<tr>`, `<td>` structure
* Markdown tables need pipe separators: `| Column | Column |`
* Add header separator: `|--------|--------|`
* Test with simple table first

***

### Links Lost in Conversion

**Problem:** Links disappear after conversion.

**Solution:**

* HTML links need proper `<a href="">` format
* Markdown links need `[text](url)` format
* Check for malformed HTML/Markdown in input
* Verify links in Text block before conversion

***

## Comparing with Other Blocks

**Use Convert to HTML/Markdown when:**

* You need to change content format (HTML ↔ Markdown)
* Converting web content for processing
* Formatting for specific platforms
* Clean HTML from web scraping

**Use Text Block when:**

* Formatting with Liquid only
* No HTML/Markdown conversion needed
* Simple text formatting and combination

**Use Code Block when:**

* Complex transformations required
* Custom parsing logic needed
* Multiple format changes
* Advanced text processing

***

## What's Next

Now that you understand the Convert to HTML/Markdown block:

* Format text with [Text Block](https://slatehq.com/docs/workflows/blocks/data-formatting/text.md)
* Process data with [Code Block](https://slatehq.com/docs/workflows/blocks/data-formatting/code.md)
* Create structured data with [Convert to JSON](https://slatehq.com/docs/workflows/blocks/data-formatting/convert-to-json.md)
* Scrape web content with [Web Scrape](https://slatehq.com/docs/workflows/blocks/data-sources/web-scrape.md)
* Generate content with [LLM Block](https://slatehq.com/docs/workflows/blocks/ai/llm.md)
* Learn [Liquid Templating](https://slatehq.com/docs/workflows/liquid-templating.md) for dynamic content
* Learn about [Variable Referencing](https://slatehq.com/docs/workflows/variable-referencing.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.