Sort Your Postman Collection

If one of your Postman collections has folders that are out of order, there are some ways to sort your Postman collection, including using a different collection that can re-order your current collection.

Or, you can sort your postman collection using jq on the command line.

  1. Export your list by clicking the … to the right of your collection name
  2. Make sure you have jq installed
  3. From your command line, run:
    • cat {filename}.json | jq '.item | sort_by(.name)' > new.json
    • This will output a sorted item section, missing the info at the top, and any non-item sections from the bottom.
  4. Open up the old and new files, so you can restore the missing pieces
  5. Copy the info portion, plus the first item line from the old file:
  1. Replace the line 1 bracket with your paste
  2. Copy the remaining pieces, plus the last bracket & comma, from the bottom of the old file
  1. Replace the last line bracket with your paste
  2. Import new.json into Postman. It will probably warn you that it’s a duplicate, and will rename it.
  3. Once you have confirmed the new collection works, you can delete the old collection, and rename the new one so it no longer says ‘Copy’.

If I’ve missed anything, please send me a message through my Contact page.