ConvertFrom-Markdown

Convert a JSON-formatted string to a custom object.

Syntax
      ConvertFrom-Markdown { [-Path] String[] | -LiteralPath String[] }
         [-AsVT100EncodedString] [CommonParameters]

      ConvertFrom-Markdown -InputObject PSObject
         [-AsVT100EncodedString] [CommonParameters]

Key
   -AsVT100EncodedString
       Specifies if the output should be encoded as a string with VT100 escape codes.

   -InputObject
       The object to be converted.
       When an object of type System.String is specified, the string is converted.
       When an object of type System.IO.FileInfo is specified, the contents of the file specified by the
       object are converted. Objects of any other type result in an error.

   -Path
       A path to the file to be converted.

   -LiteralPath
       A path to the file to be converted.
       Like -Path above, only the value is used exactly as typed.
       No characters are interpreted as wildcards. If the path includes any
       escape characters then enclose the path in single quotation marks.

ConvertFrom-Markdown converts the specified content into a MarkdownInfo.

When a file path is specified for the -Path parameter, the contents on the file are converted.

The output object has three properties:

This cmdlet was introduced in PowerShell 6.1.

Examples

Generate a markdown file by outputting an array of strings:

@(
    "# Hello World"
    "## This is some markdown"
) > ./markdown.md

Convert a file containing Markdown content to HTML:

PS C:\> ConvertFrom-Markdown -Path .\markdown.md

Convert a string containing Markdown content to HTML:

"# Markdown" | ConvertFrom-Markdown | Select-Object -ExpandProperty Html > ./output.html

Convert every markdown file in a directory to an HTML page:

foreach ($file in Get-ChildItem *.md -File) {        
    $html = (ConvertFrom-Markdown -Path $file.Fullname).html
    $html > ($file.Fullname -replace '\.md$', '.html') 
}

Convert a file containing Markdown content to a VT100-encoded string:

ConvertFrom-Markdown -Path .\README.md -AsVT100EncodedString

Convert input object containing Markdown content to a VT100-encoded string:

Get-Item .\README.md | ConvertFrom-Markdown -AsVT100EncodedString

Convert a string containing Markdown content to a VT100-encoded string:

"**Bold text**" | ConvertFrom-Markdown -AsVT100EncodedString

“I am like a drop of water on a rock. After drip, drip, dripping in the same place, I begin to leave a mark, and I leave my mark in many people's hearts” ~ Rigoberta Menchu

Related PowerShell Cmdlets

ConvertTo-Json - Convert an object to a JSON-formatted string.
ConvertFrom-String - Extract and parse structured properties from a string.
ConvertFrom-CSV - Create objects from CSV variable-length strings that are generated by ConvertTo-CSV.
invoke-WebRequest - Get content from a web page on the Internet.
Invoke-RestMethod - Send an HTTP or HTTPS request to a RESTful web service.
MarkText - WYSIWYG markdown editor.


 
Copyright © 1999-2026 SS64.com
Some rights reserved