#1098·PapaParse

transformHeader renaming and ignoring not working as expected

Author: cjrobbertse-obCreated Jun 30, 2025Updated Sep 10, 2026
Labelsunconfirmed bug

I was trying to filter out unwanted columns and rename relevant columns with transformHeader, but I could only achieve one or the other.

For example, using the following config, I was able to rename the headers that are in my headerMap, but I HAD to return header as well. as seen below.

javascript
const headerMap = {
  'Code Set': 'codeSet',
  'Code Name': 'codeName',
  'Code Value': 'codeValue',
}

const config = {
    header: true,
    skipEmptyLines: true,
    transformHeader: header => {
      if (header in headerMap) {
        return headerMap[header]
      }
      return header
    }
  }

output (as expected):

 Data: [
  {
    {codeSet: 'something'},
    {codeName: 'something else'},
    {codeValue: 'more things'},
    {description: 'some description'},
  },
    etc. etc.
]

However, when i tried to ignore the non-relevant columns by returning null when not found in my header map, the output renamed all headers to null. Even when debugging it goes into the positive if block, but still renames everything to null.

javascript
const config = {
    header: true,
    skipEmptyLines: true,
    transformHeader: header => {
      if (header in headerMap) {
        return headerMap[header]
      }
      return null
    }
  }

output looked something like:

 Data: [
  {
    {null: ''},
    {null: ''},
    {null: ''},
    {null: ''},
  },
    etc. etc.
]

Notably, when using an array of headers instead of a map and not renaming the values, the ignoring with null worked correctly.