Skip to content
TurnIntoCMS

Markdown or JSON for website content files

By Yash Garg · · 6 min read

You do not need to force your repository content into a single file format. Modern static websites rely on a hybrid setup divided by content archetype. Store long narrative prose in Markdown files, and store discrete, structured records in JSON files.

Use Markdown for documents centered on reading flow, including blog posts and documentation, as outlined in Astro's guide to markdown content. Use JSON for key-value collections, pricing tables, navigation trees, and localized interface strings. In contrast, putting multi-paragraph text into JSON requires escaping every internal quote and manually managing newline symbols.

Recommended format by content type

Content typeBest formatWhy it fitsExample file path
Blog postsMarkdownNative paragraphs and headings without escape characterscontent/posts/welcome.md
Navigation menusJSONNested key-value pairs parse directly into objectscontent/navigation.json
Team rostersJSONConsistent schemas across repeated recordscontent/authors/alex-chen.json
Legal policiesMarkdownLong-form reading flow with clear typographic hierarchycontent/legal/privacy.md
Pricing tiersJSONBoolean flags, numbers, and feature lists mapped cleanlycontent/pricing.json

Why long prose breaks down inside JSON

Standard JSON follows the strict syntax rules of RFC 8259. The specification forbids comments, rejects trailing commas, and requires string values to exist on single lines unless explicit control characters are escaped.

When you store long copy (for example, a 500-word article) inside a JSON string, you force the author to abandon natural writing patterns. Every double quote inside the copy requires an escaping backslash. Every paragraph break requires an explicit sequence like backslash-n. If an editor updates that file directly in a web browser, an accidental quote or stray backspace corrupts the file, causing runtime parsers and site builds to fail.

Git history also highlights the difference between these formats. As noted in GitHub's documentation on non-code files, GitHub provides Rich Diff rendering for Markdown files. Reviewers inspect styled additions and deletions side by side in pull requests. JSON changes appear only as dense, raw character diffs where small text edits inside long strings are difficult to track.

When JSON beats Markdown for repo data

While Markdown excels at articles, it is poorly suited for repetitive, tabular data. For entity-first records, JSON remains the superior repository format.

Structured records include navigation menus, team rosters, product feature tables, and localized interface strings. These structures rely on strict key-value pairs, nested arrays, and boolean flags. Representing them in Markdown requires awkward table syntax or custom shortcodes that are tedious to maintain and fragile to parse.

Performance also favors JSON. As described in Astro's guide on project imports, Astro supports importing JSON files directly into your application. Markdown parsing requires a compiler toolchain to tokenize text, generate an abstract syntax tree, and serialize HTML, adding unnecessary overhead for simple lists.

JSON files also integrate with JSON Schema definitions to enforce required fields and types during automated checks before code reaches production.

The hybrid pattern: frontmatter and granular files

The recommended architecture combines structured metadata and narrative copy into a unified repository layout. You place document-level metadata in frontmatter at the top of Markdown files, while storing site-wide entities in dedicated JSON files.

To minimize Git merge conflicts, avoid creating monolithic JSON files that contain dozens or hundreds of records in a single array. When two contributors add items to the bottom of the same array simultaneously, Git generates a merge conflict. Resolving it frequently results in a missing or dangling comma, which invalidates the file. As shown in Nuxt's guidance on JSON files, each file in a data collection should contain only one object.

Consider this directory structure for a typical marketing website:

  • content/posts/welcome.md (contains frontmatter for title, author, and date, followed by prose)
  • content/authors/alex-chen.json (contains id, name, avatar, and social links)
  • content/settings/navigation.json (contains header and footer link trees)

In Next.js App Router projects, Next.js project structure documentation notes that private folders prefixed with an underscore like _folderName opt a folder and all its subfolders out of routing.

Build-time validation and guardrails

Storing content in repository files introduces the risk of human error. An editor might label a publication date as published_at on one entry and pubDate on another. In Astro's content collection tutorial, defining a schema helps catch mistakes sooner with descriptive error messages.

Modern static generators eliminate this issue by enforcing schema validation at build time. Astro Content Layer and Nuxt Content integrate with Zod schemas to check frontmatter attributes and JSON fields. If a required string is missing or formatted incorrectly, the build halts with an exact line number.

Repository guardrails also prevent formatting bugs. Configure your repository .gitattributes file to normalize line endings across operating systems. Add a Prettier configuration to format Markdown and JSON files consistently before every commit, avoiding noisy whitespace diffs.

Common mistakes and how to fix them

Structuring content directly in Git repositories comes with predictable friction points:

  • Storing multi-paragraph articles inside JSON strings. Escaping quotes and newlines manually frustrates writers and causes syntax errors. Fix: Move long prose to Markdown files with frontmatter headers for metadata.
  • Creating monolithic JSON arrays with dozens of entries. Simultaneous edits at the end of the array trigger merge conflicts that break JSON commas. Fix: Adopt a one-file-per-record structure with separate JSON files for each record.
  • Allowing unvalidated frontmatter fields into templates. Inconsistent keys like pubDate versus published_at fail silently. Fix: Enforce schema validation at build time using Zod or JSON Schema definitions.
  • Adopting MDX when standard Markdown is sufficient. MDX compiles JSX at build time, increasing build times and tying content to a specific JavaScript UI framework. Fix: Use standard Markdown for editorial copy, reserving MDX only for interactive components.
  • Expecting non-technical clients to edit raw JSON files in Git. Clients editing JSON in GitHub's browser interface routinely delete quotes or commas. Fix: Connect a Git-backed CMS or visual editor so non-developers interact with clean forms instead of raw syntax.

Client editing workflows: direct files versus Git-backed tooling

Handing raw repository files to non-technical clients often leads to broken deployments. Asking a client to update a JSON file inside GitHub's web editor invites missing commas, deleted quotes, and broken builds. In addition, GitHub's file editing documentation notes that you cannot edit files in a protected branch using GitHub's browser editor.

For teams wanting a traditional form interface, a Git-based CMS for freelancers provides structured fields. Decap CMS acts as a browser-based wrapper around Git hosting APIs, as noted in the Decap CMS documentation. Similarly, the TinaCMS documentation explains that TinaCMS models collections in code and commits back to the repository whenever a user saves changes. If a client needs scheduled publishing, revision histories, or complex editorial approvals, comparing a headless CMS against content in code clarifies the right balance.

Another option is direct visual editing. TurnIntoCMS connects directly to GitHub to provide an in-place visual editor for sites built with Next.js, React, or Vite. Clients click headings, body copy, and list items on a preview of the site, and publishing writes their changes as clean Git commits to a chosen branch. TurnIntoCMS is free for one project and runs directly on existing JSX and imported data files without requiring an external database. It does not act as a page builder or create new route layouts, but it keeps clients from ever touching raw JSON syntax.

FAQ

Can you use both Markdown and JSON together in one project?

Yes. Modern static site generators encourage using both formats side by side. You store long prose like blog posts and case studies in Markdown files, while storing structured data like navigation menus, author directories, and pricing tables in JSON.

Why should you avoid storing blog posts in JSON files?

JSON strings require all text to exist without raw line breaks and require manual escaping for double quotes. This makes writing natural multi-paragraph articles painful and frequently results in broken builds due to syntax errors during client edits.

Is JSON or Markdown faster to parse during site builds?

JSON parses significantly faster because Node.js processes it natively through internal C++ bindings. Markdown requires an abstract syntax tree pipeline that parses tokens, builds an intermediate representation, and renders HTML.

Can you validate Markdown frontmatter using JSON Schema?

Yes. Parsers extract Markdown frontmatter headers into plain JavaScript objects at build time. You can validate those objects directly using standard JSON Schema definitions, Zod schemas, or TypeScript type guards.

Sources

  1. JSON - Nuxt Content (content.nuxt.com, checked November 20, 2026)
  2. Markdown in Astro (docs.astro.build, checked November 20, 2026)
  3. Build a blog tutorial: Make a content collection (docs.astro.build, checked November 20, 2026)
  4. Imports reference (docs.astro.build, checked November 20, 2026)
  5. Working with non-code files (docs.github.com, checked November 20, 2026)
  6. Decap CMS overview (decapcms.org, checked November 20, 2026)
  7. Get Started and learn about TinaCMS (tina.io, checked November 20, 2026)
  8. Project structure and organization (nextjs.org, checked November 20, 2026)
  9. Editing files (docs.github.com, checked November 20, 2026)

Related

More from the blog

Let your clients edit the site you coded

One website free. Then $1 each, paid once.

Get started free