Skip to content

parseArrays: false does not prevent parsing as arrays #543

Closed

Description

@krzysdz

With duplicates set to 'combine' (default) parseArrays: false can parse some query strings as arrays. The readme says:

qs/README.md

Lines 313 to 318 in 6bdfaf5

To disable array parsing entirely, set `parseArrays` to `false`.
```javascript
var noParsingArrays = qs.parse('a[]=b', { parseArrays: false });
assert.deepEqual(noParsingArrays, { a: { '0': 'b' } });
```

To me it suggests that with this option disabled I should never get an array. Other interpretation could be that this applies only to a[] and a[0] notations, since the "Parsing arrays" section mentions only those two notations and parsing repeating keys as arrays is mentioned only in the duplicates section (counter point: the test for a=b&a=c was literally called a simple array test in one of the first commits to this repository - 622da20).

On the current main (6bdfaf5) (should be same in 16.4.1) and 16.4.0 I see the following behaviour:

query arrayLimit parseArrays result - 6bdfaf5 result - 16.4.0
a=b&a=c Infinity false { a: [ 'b', 'c' ] } { a: [ 'b', 'c' ] }
a[]=b&a[]=c Infinity false { a: { '0': [ 'b', 'c' ] } } { a: { '0': [ 'b', 'c' ] } }
a=b&a=c Infinity true { a: [ 'b', 'c' ] } { a: [ 'b', 'c' ] }
a[]=b&a[]=c Infinity true { a: [ 'b', 'c' ] } { a: [ 'b', 'c' ] }
a=b&a=c -1 false { a: { '0': 'b', '1': 'c' } } { a: [ 'b', 'c' ] }
a[]=b&a[]=c -1 false { a: { '0': { '0': 'b', '1': 'c' } } } { a: { '0': [ 'b', 'c' ] } }
a=b&a=c -1 true { a: { '0': 'b', '1': 'c' } } { a: [ 'b', 'c' ] }
a[]=b&a[]=c -1 true { a: { '0': 'b', '1': 'c' } } { a: [ 'b', 'c' ] }

This is not what I would expect based on the documentation (readme), but I think I may know the historical reason for this behaviour. arrayLimit was intended (until 16.4.1) to restrict only arrays with explicit indexes (see 4667c41, 8c5cda3, #294 and a longer analysis in #537 (comment)) and I believe parseArrays: false was meant to replace arrayLimit: -1 (#60, cc735a5) and affect the notation with indices, not repetitions (8e299ca).

This is related also to #260 and 2b94ea7, which extended parseArrays from indexed-only to also apply to [] notation, without index.

I think this is a documentation "bug" that requires clarification or maybe a combination of documentation and code problems (especially with changes to 6.14.1), but this requires answering some questions:

Activity

  1. ljharb commented on Jan 24, 2026

    @ljharb
    Owner

    I agree it's a documentation issue. parseArrays: false doesn't mean "no arrays are produced", it means "array syntax does not produce an array".

  2. added a commit that references this issue on Feb 11, 2026
    5c308e5
  3. added 14 commits that reference this issue on Feb 13, 2026
    3cb338b
    73a7790
    69a0228
    32adc9d
    fb448d2
    a148d1e
    6de39c3
    2b9b819
    dbb0346
    f2c4c54
    16975e2
    6b5401e
    ad1078f
    da72b12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions