Property Flattener

Last updated:

What does the Property Flattener app do?

This app flattens nested properties in PostHog events, making it easier to access them through filters if needed.

This is useful if, for example, you're an online retailer and have purchase events with the following property structure:

{
"event": "purchase",
"properties": {
"product": {
"name": "AZ12 shoes",
"type": "footwear",
"size": {
"number": 12,
"gender": "M"
}
}
}
}

This app will keep the nested properties unchanged, but also add any nested properties at the first depth, like so:

{
"event": "purchase",
"properties": {
"product": {
"name": "AZ12 shoes",
"type": "footwear",
"size": {
"number": 12,
"gender": "M"
}
},
"product__name": "AZ12 shoes",
"product__type": "footwear",
"product__size__number": 12,
"product__size__gender": "M"
}
}

As such, you can now filter your purchase events based on productsizenumber for example.

What are the requirements for this app?

The Property Flattener requires either PostHog Cloud, or a self-hosted PostHog instance running version 1.30.0 or later.

Not running 1.30.0? Find out how to update your self-hosted PostHog deployment!

How do I install the Property Flattener?

  1. Visit the 'Apps' page in your instance of PostHog.
  2. Search for 'Property Flattener' and select the app, press Install.
  3. Follow the on-screen steps to configure the app.

How do I separate nested properties?

The default separator for nested properties is two subsequent underscores (__), but you can also change this to:

  • .
  • >
  • /

When picking your separator, make sure it will not clash with your property naming patterns! There be dragons.

Configuration

OptionDescription
Select a separator format for accessing your nested properties
Type: choice
Required: True
For example, to access the value of 'b' in a: { b: 1 } with separator '', you can do 'ab'

Is the source code for this app available?

PostHog is open-source and so are all apps on the platform. The source code for the Property Flattener is available on GitHub.

Who created this app?

We'd like to thank PostHog team members Yakko Majuri, Tim Glaser and Marius Andra and community member Chasovskiy for creating the Property Flattener.

Who maintains this app?

This app is maintained by PostHog. If you have issues with the app not functioning as intended, please raise a bug report to let us know!

What if I have feedback on this app?

We love feature requests and feedback! Please create an issue to tell us what you think.

What if my question isn't answered above?

We love answering questions. Ask us anything via our Support page.

You can also join the PostHog Community Slack group to collaborate with others and get advice on developing your own PostHog apps.

Questions?

Was this page useful?

Next article

Schema Enforcer

How does this app work? The app enables you to enforce a schema on events in PostHog as they are ingested. It does this by preventing ingestion if the event: Is missing a required property Has a property with the wrong type Is not included in the file and onlyIngestEventsFromFile is true It also: Removes all other properties from an event except selected ones if acceptOnlySchemaProps is true Configuration is done via a JSON file uploaded as an attachment What are the requirements for this app…

Read next article