GitHub Actions fromJSON Errors - Invalid JSON in a Dynamic Matrix
fromJSON received something that is not valid JSON - an empty string, plain text, or output that was never serialized - so the expression cannot parse it into an object or array.
What this error means
A workflow using fromJSON(...) fails to compile or errors at runtime parsing the value, often when feeding a matrix from a job output that was not valid JSON.
Actions annotation
The workflow is not valid. Error parsing fromJSON: Unexpected token while parsing value: e
# the output was "ext" not a JSON array like ["ext"]Common causes
Output is not JSON
fromJSON needs a valid JSON string. A raw word, a space-separated list, or human text fails to parse.
Empty or missing output
If the producing step wrote nothing to GITHUB_OUTPUT, fromJSON gets an empty string, which is not valid JSON.
How to fix it
Emit valid JSON from the producer
Serialize the value as JSON (a quoted array/object) in the producing step before consuming it with fromJSON.
.github/workflows/ci.yml
- id: set
run: echo 'matrix=["18","20","22"]' >> "$GITHUB_OUTPUT"
# consumer
strategy:
matrix:
node: ${{ fromJSON(needs.prep.outputs.matrix) }}Validate the JSON before use
- Build JSON with a tool like jq -c so it is always well-formed.
- Echo the output string and confirm it parses (jq . <<< "$out").
- Default to a valid empty array "[]" and guard the consumer against it.
How to prevent it
- Serialize matrix/list outputs with jq so they are valid JSON.
- Echo and validate the JSON string before feeding fromJSON.
- Default to a well-formed value and handle the empty case.
Related guides
GitHub Actions "Matrix vector 'x' does not contain any values"Fix GitHub Actions "Matrix vector `x` does not contain any values" - a matrix dimension set to null, an empty…
GitHub Actions "Unexpected symbol" in a ${{ }} ExpressionFix GitHub Actions "The workflow is not valid ... Unexpected symbol" - a malformed expression: unquoted strin…
GitHub Actions "Invalid pattern" in a paths / branches FilterFix GitHub Actions "Invalid pattern `x`" - a malformed glob in a paths, paths-ignore, branches, or tags filte…