# Logfmt to JSON Structured Log Bridge

Convert logfmt (key=value) to JSON or JSON back to logfmt, with quote escaping, number/boolean coercion, and duplicate-key handling.

> Canonical page: https://elysiatools.com/en/tools/logfmt-to-json-structured-log-bridge

- **Category:** Format Conversion

- **Keywords:** logfmt, json, log, structured, heroku, loki, vector, observability, convert, sre

## Overview

logfmt (key=value pairs separated by spaces) is the native format of syslog-ng, Heroku log drains, Vector, Grafana Loki, and many Go logging libraries. This tool converts it to structured JSON for ingestion into ELK/Datadog/Splunk — and back. It handles quoted values with embedded spaces and escaped quotes, coerces numeric and boolean strings to typed JSON values, and lets you choose how duplicate keys are treated (warn-last-wins, collect into an array, or strict error).

## Inputs

- **Input** (textarea): level=info msg="server started" port=8080 ts="2026-07-25T10:00:00Z"
- **Direction** (select)
- **Coerce Numbers** (checkbox)
- **Coerce Booleans** (checkbox)
- **Drop Null Values** (checkbox)
- **Duplicate-Key Mode** (select)
- **Indent JSON (spaces)** (number)

## When to use

- Convert application or service logfmt entries into structured JSON for log analysis workflows.
- Turn JSON log records into compact logfmt for systems and libraries that use key=value output.
- Check how duplicate keys, quoted spaces, escaped quotes, numbers, booleans, and null values are represented.

## How it works

- Enter a logfmt record or JSON object in the Input field.
- Choose either logfmt → JSON or JSON → logfmt.
- Enable or disable number coercion, boolean coercion, and null-value removal as needed.
- Choose duplicate-key behavior and set JSON indentation from 0 to 8 spaces, then read the text result.

## Use cases

- Prepare logfmt records as structured JSON for ELK, Datadog, Splunk, or other JSON-based log workflows.
- Convert JSON records into logfmt for Heroku-style logs, Vector pipelines, or Go logging workflows.
- Normalize log fields while preserving quoted messages and choosing an explicit duplicate-key policy.

## Frequently asked questions

### What input formats does this tool support?

It accepts logfmt key=value text and JSON, depending on the selected conversion direction.

### Can quoted logfmt values contain spaces?

Yes. Quoted values with embedded spaces and escaped quotes are supported.

### How are numbers and booleans converted?

When enabled, numeric and boolean strings are converted to typed JSON values during logfmt to JSON conversion.

### How does the tool handle duplicate keys?

You can warn and use the last value, collect values into an array, or return a strict error.

### Can null values be removed?

Yes. Enable Drop Null Values to omit null values from the converted output.

## Related tools

- [JSON Key Extractor](https://elysiatools.com/en/tools/json-key-extractor): Extract all keys from JSON objects with multiple output formats. Perfect for analyzing JSON structure, documentation generation, and understanding complex nested objects.
- [ECharts Theme Token Extractor](https://elysiatools.com/en/tools/echarts-theme-token-extractor): Extract design tokens — colors, numbers, font sizes and strings — from an ECharts theme JSON and export them straight into your design system. Paste a theme object (the kind registered via echarts.init(dom, themeName)) and the tool walks every leaf, tagging each color (with optional named/rgb → hex normalization), spacing number, font size and string, then emits clean CSS variables, a Tailwind theme.extend config, Style Dictionary tokens.json, or SCSS variables. Bridges the gap between an ECharts visualization theme and Figma/CSS/Tailwind design tokens without copying each value by hand.
- [Image Palette to Design Tokens](https://elysiatools.com/en/tools/image-to-design-tokens): Extract a dominant color palette from an image (k-means clustering), then export it as CSS variables, SCSS variables, a Tailwind config, or JSON design tokens — with named colors and an auto-generated shade scale for each
- [OpenAPI to Postman Collection](https://elysiatools.com/en/tools/openapi-to-postman-collection): Turn an OpenAPI 3.x or Swagger 2.0 spec (JSON/YAML) into an importable Postman Collection v2.1.0 with folders, variables, auth and example responses.
- [Range Chart Generator](https://elysiatools.com/en/tools/range-chart-generator): Create range charts to visualize min-max value ranges with median markers and outlier detection
- [BOM Character Remover](https://elysiatools.com/en/tools/data-bom-remover): Remove BOM (Byte Order Mark) characters from text and file content. Perfect for cleaning up text files that have encoding issues, fixing CSV imports, and preparing data for processing. Features: - Detect and remove UTF-8 BOM (EF BB BF) - Detect and remove UTF-16 BOM (FE FF or FF FE) - Detect and remove UTF-32 BOM (00 00 FE FF or FF FE 00 00) - Support multiple input formats - Visual BOM character display - Detailed detection report - Support for batch text processing Common Use Cases: - Fix CSV file import errors - Clean up text file encoding issues - Prepare data for JSON parsing - Fix XML parsing problems - Resolve API data encoding conflicts - Standardize text data format
- [Data Range Limiter](https://elysiatools.com/en/tools/data-range-limiter): Limit numerical values to specified ranges by clipping, filtering, or marking out-of-bounds values. Perfect for data quality control, sensor data cleaning, business rule enforcement, and data preprocessing. Features: - Range clipping (clip values to min/max boundaries) - Range filtering (remove out-of-bounds rows) - Range marking (flag modified values) - Per-column range configuration - Automatic numeric column detection - Multiple handling strategies - Detailed modification reports - Statistical analysis of changes - Business rule enforcement Common Use Cases: - Sensor data validation and cleaning - Machine learning input preparation - Data quality control and validation - Business constraint enforcement - Outlier management and control - Data preprocessing pipelines
- [Sports Data JSON Visualizer](https://elysiatools.com/en/tools/sports-data-json-visualizer): Paste a JSON payload from any sports API (ESPN, TheSportsDB, balldontlie, football-data.org, api-sports.io) and get it rendered as a clean scoreboard with winners highlighted and game statuses.

## Samples

- [Terraform Plan JSON Samples](https://elysiatools.com/en/samples/terraform-plan-json-samples): Sample Terraform plan JSON files exported from terraform show -json style payloads for dependency visualization and change review
- [Chat Transcript JSON Samples](https://elysiatools.com/en/samples/chat-transcript-json): JSON examples for multi-role chat transcripts
- [JSON Samples](https://elysiatools.com/en/samples/json): JSON (JavaScript Object Notation) format examples from simple to complex structures
- [Rich Media JSON Samples](https://elysiatools.com/en/samples/rich-media-json): JSON examples for popular rich text editors (TipTap, Quill, Slate)

## Related content

- [Semi-Structured Text Parsing and Table Extraction](https://elysiatools.com/en/hubs/semi-structured-text-table-extraction): Parse fixed-width records, messy delimited text, logs, Markdown tables, and HTML tables into CSV, JSON, XML, or Excel with reviewable cleanup steps.
