Translate Markdown table rows and headers into structured, indented YAML configurations.
The conversion process utilizes a deterministic parsing algorithm that scans Markdown table syntax, specifically identifying the pipe-delimited boundaries | and the alignment row ---|---. The engine first strips leading and trailing pipes, then splits the header row to establish the YAML keys. Each subsequent data row is processed as a unique object within a YAML sequence, mapping the column index to the corresponding header key to ensure strict data integrity during the transformation.
This tool is engineered for high-fidelity data migration, supporting complex table structures without losing semantic meaning. Key technical capabilities include:
list of maps, which is the industry standard for configuration-as-code and Kubernetes manifest generation.To transform your data, paste your Markdown table into the input area. The parser will validate the symmetry between the header row and the data rows. For developers integrating this logic into a pipeline, you can simulate the conversion using a Python-based approach with the PyYAML library:
import yaml
import re
def md_to_yaml(md_table):
lines = [l.strip() for l in md_table.strip().split('\n') if not l.startswith('---')]
headers = [h.strip() for h in lines[0].split('|') if h.strip()]
data = []
for line in lines[1:]:
cols = [c.strip() for c in line.split('|') if c.strip()]
data.append(dict(zip(headers, cols)))
return yaml.dump(data, default_flow_style=False)
print(md_to_yaml("| Name | Role |\n|---|---|\n| Alice | Dev |"))Alternatively, for JavaScript/Node.js environments, you can utilize the js-yaml package to handle the object serialization after splitting the string by newline and pipe delimiters.
Data privacy is paramount when handling configuration files. This tool operates on a client-side processing model, meaning the transformation occurs within the browser's memory space. No data is transmitted to a remote server, mitigating the risk of intercepting sensitive environment variables or API keys stored in your tables. To maintain security, follow these guidelines:
sed or envsubst in your local shell.yamllint check to ensure the indentation adheres to the YAML 1.2 specification.When the parser encounters an empty cell (e.g., ||), it assigns a null value or an empty string to the corresponding YAML key. This ensures that the structure of the YAML list remains consistent across all entries, preventing index shift errors that would occur if the key were simply omitted. This behavior is critical for maintaining schema validation in strictly typed environments.
Standard Markdown tables do not natively support multi-line cells; however, this tool handles cells containing
tags or escaped newline characters by converting them into YAML block scalars. By using the '|' or '>' indicators in YAML, the tool preserves the intended line breaks, ensuring that long-form descriptions are not collapsed into a single line of text.
The tool employs a 'Header-First' priority logic. If a data row contains more columns than the header, the trailing columns are ignored to prevent the creation of anonymous keys. Conversely, if a data row has fewer columns, the remaining header keys are populated with null values. This prevents the resulting YAML from becoming malformed and ensures it can be parsed by standard YAML loaders.
Yes, the output is generated to be compatible with both YAML 1.1 and 1.2. It avoids using complex tags and focuses on the core schema of sequences and mappings. By adhering to the standard two-space indentation and avoiding ambiguous boolean representations, the output is guaranteed to be readable by virtually any YAML parser, including those in Ruby, Python, and Go.
The tool uses an optimized linear-time complexity algorithm, O(n), where n is the number of characters in the input string. Because the processing happens locally in the browser's JavaScript engine, it avoids the latency of HTTP requests. For tables with thousands of rows, the tool utilizes efficient string splitting and array mapping to ensure the UI remains responsive without freezing the main thread.