Skip to content
Latchkey

GitHub Actions fromJSON "Unexpected end of JSON input"

fromJSON parses its argument as JSON. An empty output, a truncated multiline value, or an unset variable yields an empty string, which is not valid JSON and fails to parse.

What this error means

A matrix or value built with fromJSON fails at evaluation time, usually because the source step output was empty or got cut off.

github-actions
Error: Unexpected end of JSON input while parsing ''

Common causes

Source output is empty

The step that should produce JSON wrote nothing to GITHUB_OUTPUT, so fromJSON gets an empty string.

Multiline JSON output truncated

Writing multiline JSON to GITHUB_OUTPUT without a heredoc delimiter truncates it.

How to fix it

Emit valid, complete JSON

  1. Confirm the producing step prints non-empty JSON and writes it to GITHUB_OUTPUT.
  2. For multiline JSON, use a heredoc delimiter when writing to GITHUB_OUTPUT.
  3. Guard with a default like fromJSON(steps.gen.outputs.json || '[]').
.github/workflows/ci.yml
- id: gen
  run: |
    {
      echo 'json<<EOF'
      cat matrix.json
      echo 'EOF'
    } >> "${GITHUB_OUTPUT}"

How to prevent it

  • Always validate that the JSON-producing step emits non-empty output.
  • Use heredoc delimiters for any multiline GITHUB_OUTPUT value.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →