portfolios.tools

YAML to JSON Converter

Convert supported YAML block data into formatted JSON and inspect value types.

YAML input

Paste YAML text to see the JSON conversion and value types.

Worked example

portfolio:
  name: "Growth"
  holdings:
    - symbol: "00123"
      targetWeight: 0.6
    - symbol: BND
      targetWeight: 0.4
Conversion result

Conversion result

{
  "portfolio": {
    "name": "Growth",
    "allocation": {
      "stocks": 80,
      "bonds": 20
    }
  }
}

Value type summary

Root valueobject
/portfolioobject
/portfolio/namestring
/portfolio/allocationobject
/portfolio/allocation/stocksnumber
/portfolio/allocation/bondsnumber

How it works

Paste a YAML configuration that uses block mappings and sequences. The converter reads indentation to build nested JSON objects and arrays. It preserves quoted strings and handles supported plain strings, booleans, null values, and safe decimal numbers.

Review the formatted JSON and the type summary. The summary identifies values by JSON Pointer style paths and includes each array item. Copy the JSON only after checking that its structure and values match what your application expects.

Comments are removed from the parsed value, as JSON has no comment syntax. Empty mapping values become null unless followed by an indented child block, in which case they contain that nested collection. Unquoted numeric identifiers follow YAML Core scalar resolution, so quote identifiers when zeros or formatting must be retained.

Use this page for a quick syntax conversion of small configuration snippets. For production use, validate the converted JSON against the application's schema and test the data before relying on it.

Step by step

  1. Paste YAML using the supported block syntax
  2. Review errors, JSON, and the type summary
  3. Copy the JSON after checking its values

Worked example

Paste the displayed YAML example. The parser produces a JSON object with a portfolio name and two holdings. The quoted symbol 00123 remains a string, while target weights 0.6 and 0.4 become numbers.

The test for this example expects the same values in formatted JSON, including the string symbol and both numeric weights. No weights are added, normalized, or otherwise changed by the converter.

When to use this converter

Use the converter when a small YAML configuration needs to be represented as JSON for inspection or for an application that accepts JSON.

For deployment or financial use, run the result through the schema and validation checks required by the receiving application.

Common mistakes

Do not assume that valid JSON means a valid portfolio configuration. Check required keys, value types, and any application specific constraints after conversion. Quote ticker or account identifiers that could be interpreted as numbers.

Do not use this converter for YAML features it does not support. Anchors, aliases, tags, flow collections, block scalars, and multiple documents produce errors rather than an equivalent JSON value.

Conversion steps

YAML text → parse supported block structures and scalars → serialize the resulting JSON value with two space indentation

This is a syntax conversion, not schema validation. The parser supports block mappings and sequences, quoted strings, comments, the YAML Core boolean spellings true, True, TRUE, false, False, FALSE and null spellings null, Null, NULL, ~, plus safe finite decimal numbers. It rejects unsupported YAML features and produces no partial JSON on errors. Quote identifiers such as 00123 when they must remain strings.

Limitations and assumptions

This converter implements a limited YAML subset, not a complete YAML parser. It rejects anchors, aliases, tags, directives, multiple documents, complex keys, flow collections such as inline arrays or objects, and block scalars. Boolean and null resolution is limited to the spellings listed above. Special floats, base prefixed numbers, numeric separators, and decimal forms outside the supported syntax are rejected. It does not validate an application schema or portfolio meaning. Inputs are limited to 250,000 characters, 10,000 lines, and 64 nested levels. Unsafe or high precision numbers are rejected because converting them could change their value. Quote identifiers such as 00123 when leading zeros must remain part of the string. Parsing runs in your browser, and the latest input may be saved in localStorage on this device.

Key terms

Mappings and sequences
A mapping stores values under string keys. A sequence is an ordered list represented by a JSON array.
Type summary path
A JSON Pointer style path identifies a value by its object keys and array indexes, for example /portfolio/holdings/0/symbol.
Parsed value type
A parsed type describes the JSON value only. It does not indicate that the value meets a portfolio or application schema.

Compare alternatives

This tool converts a bounded subset of YAML 1.2 block syntax to JSON. For spreadsheet data, use CSV to Financial JSON Converter. Neither converter checks whether a portfolio configuration is financially appropriate.

After conversion, validate the JSON against the schema your application expects. A successful parse confirms syntax for this supported subset only. It does not validate required fields, portfolio weights, tickers, or trading instructions.

FAQ

How does this YAML to JSON converter work?

The converter reads indented block mappings and sequences, then serializes the parsed value as JSON. It supports nested collections, quoted strings, comments, null, booleans, and finite decimal numbers within safe precision. It implements a limited subset, not the complete YAML specification.

How are YAML values converted to JSON types?

The Core spellings true, True, and TRUE become booleans, as do false, False, and FALSE. The spellings null, Null, NULL, and ~ become JSON null. Supported decimal values become numbers. Quoted values remain strings. Other plain values are strings. YAML Core resolves an unquoted value such as 00123 as a number, so quote identifiers when leading zeros must be preserved.

What does the type summary show?

The type summary uses JSON Pointer style paths, with array indexes included. For example, /portfolio/holdings/0/symbol identifies the first holding's symbol. It reports the parsed JSON type and does not check an application schema.

How should I indent nested mappings and sequences?

Indentation defines nested blocks. Use spaces, keep child entries at a consistent indentation level, and do not use tabs for indentation. The parser reports indentation problems instead of guessing at the intended structure.

What happens when input is invalid or unsupported?

The converter reports an error and returns no JSON when it encounters unsupported or malformed input. Correct the indicated line where available, then parse again. It rejects features such as anchors, aliases, tags, flow collections, block scalars, and multiple documents.

Related tools

Use CSV to Financial JSON Converter when the source is a spreadsheet export. Use a JSON validator or your application's own schema checks after conversion. This page changes data format only and does not assess portfolio allocations or investment choices.