From ebc6056adc341b1bcc7c940262391c2b4c7223b6 Mon Sep 17 00:00:00 2001 From: Varun Chawla <34209028+veeceey@users.noreply.github.com> Date: Fri, 13 Mar 2026 12:10:23 -0700 Subject: [PATCH] docs: clarify silentJSONParsing requires explicit responseType: 'json' (#7398) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: make silentJSONParsing: false work without explicit responseType Setting transitional.silentJSONParsing to false had no effect unless responseType was also explicitly set to 'json'. This was because strictJSONParsing required JSONRequested (responseType === 'json') to be true, but the default responseType is undefined. Now strictJSONParsing is also enabled when forcedJSONParsing is active (the default) and no explicit responseType is set, which matches the documented behavior that silentJSONParsing controls whether parse errors are thrown. Fixes #7253 * docs: clarify silentJSONParsing requires explicit responseType: 'json' Reverted the code change and updated docs instead — silentJSONParsing only takes effect when responseType is explicitly set to 'json', which is by design. Updated the README to make this behavior clear and show the correct usage pattern. --------- Co-authored-by: Jay --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0539176e..ef1cbdad 100644 --- a/README.md +++ b/README.md @@ -624,7 +624,12 @@ These are the available config options for making requests. Only the `url` is re transitional: { // silent JSON parsing mode // `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour) - // `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json') + // `false` - throw SyntaxError if JSON parsing failed + // Important: this option only takes effect when `responseType` is explicitly set to 'json'. + // When `responseType` is omitted (defaults to no value), axios uses `forcedJSONParsing` + // to attempt JSON parsing, but will silently return the raw string on failure regardless + // of this setting. To have invalid JSON throw errors, use: + // { responseType: 'json', transitional: { silentJSONParsing: false } } silentJSONParsing: true, // default value for the current Axios version // try to parse the response string as JSON even if `responseType` is not 'json'