Форматтер JSON

Форматирует JSON, проверяет структуру и минифицирует вывод.

// about

Об этом инструменте

Текст JSON может быть трудно прочитать, если он записан в одну строку. Этот инструмент добавляет переносы строк и отступы для удобства.

Как использовать

  1. Вставьте ваш текст JSON в верхнее поле.
  2. Нажмите 'Запустить' или выберите 'Сжать'.
  3. Скопируйте готовый результат.

Зачем используют этот инструмент

  • Делает код JSON понятным и аккуратным в один клик.
  • Быстро находить пропущенные кавычки или запятые.
  • Умеет сжимать текст (minify) для быстрой передачи.

Часто задаваемые вопросы (FAQ)

Что такое JSON?

JSON — это простой формат для обмена данными между компьютерами с помощью фигурных скобок.

Сохраняются ли мои данные на сервере?

Нет, все вычисления происходят прямо в вашем браузере.

Что делать, если появилась ошибка?

Проверьте, не забыли ли вы поставить кавычку или запятую в исходном тексте.

Руководства · Данные · 8 мин чтения

Как исправить синтаксические ошибки JSON: 7 самых частых ошибок и приведение JSON в порядок

Ответы API, конфигурационные файлы, логи — JSON остаётся форматом данных, который разработчики читают чаще всего. И всё же одна запятая или кавычка может вызвать ошибку «Unexpected token». Вот как быстро найти причину.

JSON (JavaScript Object Notation) — текстовый формат, стандартизированный в RFC 8259 и ECMA-404. Он появился в JavaScript, но сейчас поддерживается почти всеми языками. Типов значений всего шесть: строка, число, логическое значение (true/false), null, массив и объект.

{
  "id": 1024,
  "name": "AIBIZAP",
  "active": true,
  "tags": ["tools", "guides"],
  "owner": null
}
Основы JSON, семь ошибок, вызывающих сбои разбора, подводные камни больших чисел и дат, а также как превратить JSON в классы или таблицы базы данных.
Читать →
Сделать с ИИ

Создайте этот инструмент сами с помощью ИИ

Нужна своя версия? Скопируйте промпт в чат с ИИ или сохраните файл навыка для ИИ-агента. В них описаны функции, особые случаи и тесты, которые мы использовали.

Промпт и навык даны на английском — ИИ-инструменты хорошо его понимают.

Промпт-задание для ИИ

Вставьте как есть в Claude, ChatGPT или Gemini.

You are an experienced full-stack web developer. Build a web tool called "Форматтер JSON" that meets the requirements below.

## Goal

Build a tool that validates JSON and pretty-prints or minifies it.

## Core features

- Validation with error line and column
- Indent with 2 spaces, 4 spaces or tabs
- Minify mode
- Optional alphabetical key sorting
- Copy result and download as .json

## Inputs

- JSON text
- Indentation, sorting and mode options

## Outputs

- Formatted or minified JSON
- Error message with position

## Edge cases and handling rules

- Explain common errors such as trailing commas, single quotes and comments in plain language
- Preserve integers larger than 2^53 exactly
- Strip a leading BOM
- Stay responsive with multi-megabyte input

## Implementation requirements

- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.
- Make the UI responsive and easy to use on mobile; label every input and keep everything keyboard accessible.
- Add a Copy button for results and show clear, friendly error messages for invalid input.
- Keep the core logic in functions separate from the UI so it can be unit-tested.

## Definition of done (test cases)

- '{"a":1,}' is reported as a trailing comma error
- Formatting then minifying keeps the same meaning
- 12345678901234567890 is preserved

First outline your implementation plan in at most five lines, then write the complete code, and finally explain how to check the test cases above.

Навык (SKILL.md)

Сохраните как .claude/skills/build-json-formatter/SKILL.md, чтобы агенты вроде Claude Code использовали его при каждой доработке инструмента.

---
name: build-json-formatter
description: Use when building or changing a Форматтер JSON tool. Build a tool that validates JSON and pretty-prints or minifies it.
---

# Build: Форматтер JSON

## Goal

Build a tool that validates JSON and pretty-prints or minifies it.

## Workflow

1. Review the required features, inputs and outputs below and ask about anything missing first.
2. Implement the core logic as pure functions separate from the UI.
3. Check the logic against the test cases in the verification list.
4. Build a responsive UI with an input form, a result area and a Copy button.
5. Reproduce each edge case listed under Rules and refine the error messages.

## Core features

- Validation with error line and column
- Indent with 2 spaces, 4 spaces or tabs
- Minify mode
- Optional alphabetical key sorting
- Copy result and download as .json

## Inputs

- JSON text
- Indentation, sorting and mode options

## Outputs

- Formatted or minified JSON
- Error message with position

## Rules

- Explain common errors such as trailing commas, single quotes and comments in plain language
- Preserve integers larger than 2^53 exactly
- Strip a leading BOM
- Stay responsive with multi-megabyte input
- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.

## Verification

- [ ] '{"a":1,}' is reported as a trailing comma error
- [ ] Formatting then minifying keeps the same meaning
- [ ] 12345678901234567890 is preserved

Советы по работе с ИИ

  • Укажите стек (React, Vue или чистый HTML) в первой строке, чтобы код подошёл к проекту.
  • Попросите ИИ выполнить перечисленные тесты и показать результаты до принятия кода.
  • Не вставляйте настоящие пароли, данные клиентов и API-ключи; используйте примеры.