← Blog

dif vs PostHog: a flag tool against an analytics suite

dif and PostHog both ship feature flags, and the real difference is scope, not quality. dif is a flag-and-experiment tool and nothing else: each flag or experiment is a Markdown file in your repo, reviewed in a pull request. PostHog bundles feature flags into a much bigger product, alongside product analytics, session replay, surveys, error tracking, and more, managed from one app.

Both are open source. PostHog’s core is MIT licensed, with a handful of enterprise features under a separate license. dif’s CLI and SDK are fully MIT, and there is nothing separate to host: no app, no database, just files in the repo you already have. This post compares dif vs PostHog on where flags live, what each is built for, and what it costs to run either one.

Key Takeaways

  • dif and PostHog are both open source. PostHog’s core is MIT licensed, with some enterprise features under a separate license. dif’s CLI and SDK are fully MIT, with nothing separate to host.
  • dif keeps flags and experiments as Markdown files in your repo. PostHog manages them inside a broader app that also runs product analytics, session replay, surveys, and error tracking.
  • PostHog ships feature flags as one of eight-plus bundled products, with SDKs in 20+ languages and a free tier of 1 million flag requests a month.
  • dif is built for flags and experiments only: a ~5 kB SDK with no network call to assign a variant, and a context.json a coding agent can read. The SDK covers JavaScript and TypeScript only.
  • Pricing splits on model: PostHog bills per flag request with no flat fee; dif Cloud is a flat $50/mo for 1 million events, unlimited seats.

What PostHog does well

PostHog is a product-analytics platform that happens to include feature flags, not a flags tool that grew analytics on the side. One app covers product analytics, session replay, surveys, error tracking, a data warehouse, logs, and feature flags and experiments together.

That bundling is the real strength. If your team already runs PostHog for analytics, flags are already there. You skip a second tool, a second bill, and a second dashboard to teach a new PM. Flags and experiments draw from one usage meter alongside your other PostHog products.

SDK coverage is wide: more than 20 languages and platforms, including Python, Go, Java, Ruby, PHP, Rust, and mobile SDKs for iOS, Android, and Flutter, plus OpenFeature support. Server SDKs can run local evaluation against a cached copy of your flag definitions, polled down with a secret API key, so most requests don’t round-trip to PostHog’s API. The free tier is generous: 1 million feature flag requests a month at no cost, no credit card required.

For a team that wants analytics, replay, and flags under one roof and one bill, PostHog is built for exactly that. dif does not compete on that breadth.

Where dif is different

dif starts from a narrower claim: a feature flag is part of your codebase, so it should live in your repo, not inside an analytics app. Each flag or experiment is one Markdown file next to the code it gates.

---
id: trial-length-14-days
status: active
owner: priya@acme.com
surface: onboarding
hypothesis: >
  A 14-day trial lifts activated-to-paid conversion over the current 7-day trial.
variants:
  - id: control
    weight: 50
  - id: fourteen_day
    weight: 50
metrics:
  primary: activated_to_paid
  guardrails:
    - support_tickets
---

You review that file in a pull request, and dif validate runs in CI, so a broken flag fails the build the same way a broken test does. There is no separate app to open and no dashboard state that can drift from what’s in the repo. A flag and an experiment share one format, so a test that wins becomes a flag you ramp by editing the weights, without touching application code.

Because the flags are files, a coding agent can read them. dif build writes a context.json of every active flag and each surface’s latest learning, which an analytics dashboard has no way to hand an agent. The runtime SDK is about 5 kB, zero dependencies, and makes no network call to assign a variant: the bucket is computed locally from the user ID. That’s the same git-native model behind feature flags in git and the agent-readable side of it is covered in context.json, explained.

The cost of that narrowness: dif’s SDK is JavaScript and TypeScript only, and it ships no analytics product alongside it. If you need a backend SDK in Go or Ruby, or want flags and analytics in the same product, that’s a point for PostHog.

dif vs PostHog, side by side

DimensiondifPostHog
Where flags and experiments liveMarkdown files in your repoThe PostHog app, alongside analytics, replay, surveys
LicenseOpen source (MIT)Mostly MIT; some enterprise features under a separate license
Source of truthThe repo, reviewed in pull requestsThe app UI and API
Product scopeFlags and experiments onlyFlags and experiments bundled with analytics, replay, surveys, error tracking, and more
SDK languagesJavaScript and TypeScript (React, Svelte)20+, including Python, Go, Java, Ruby, PHP, Rust, and mobile
Runtime evaluation~5 kB, zero dependencies, no network call to assignClient SDKs call the /flags endpoint; server SDKs poll a cached copy with a secret key
Agent-readable stateYes (context.json)No
Separate app to runNoYes (self-host, or PostHog Cloud)
Change a flagCommit and deployToggle in the app
Free tier / hosted pricing$50/mo for 1M events, unlimited seatsFree to 1M flag requests/mo, then from $0.0001/request

PostHog wins on breadth: more SDK languages, a bundled analytics suite, and a UI non-engineers can click through without a PR. dif wins where its model does: the flags are in the repo, there’s no separate app, the state is agent-readable, and the SDK makes no call to decide what a user sees.

Pricing

Both are cheap to start, and the two models price on different axes.

PostHog’s feature flags and experiments share one usage meter. The first 1 million flag requests a month are free, then PostHog’s published rate card starts at $0.0001 per request from 1 to 2 million, stepping down as volume grows, to roughly $0.00001 per request past 50 million. There’s no flat fee and no seat charge: you pay for requests, across whichever PostHog products you use.

dif Cloud is a flat $50 a month for 1 million events, then $0.02 per 1,000 events, with unlimited seats. That $50 applies from the first event; there is no free dif Cloud tier, though the CLI and SDK run with no cloud at all if you skip hosted analytics entirely. At 5 million events a month, PostHog’s tiers come to roughly $235, and dif Cloud comes to roughly $130.

Which is cheaper depends on shape. A team already paying for PostHog’s other products absorbs flags into one bill, and that convenience has real value. A team that only wants flags and experiments, with no analytics suite attached, pays for a smaller, single-purpose meter instead.

Who should choose which

Choose PostHog if you want feature flags bundled with product analytics, session replay, surveys, and error tracking in one app, you need a backend SDK outside JavaScript and TypeScript, or non-engineers should toggle flags without opening a pull request.

Choose dif if you want flags and experiments as files in the repo, reviewed like code, with nothing extra to run, and your stack is JavaScript or TypeScript. It fits teams that don’t want an analytics platform bolted onto their flagging, and teams giving a coding agent a readable view of what’s gated and what’s already been tried.

Moving from PostHog to dif

There’s no one-click import, because the two store flags in different places. Moving a flag means recreating it as a .md file with the same variants and weights, gating the code path with a dif("flag-id") call, and running dif validate. Because the flag is now a file, the migration itself is a normal pull request. Move a handful of active flags first, not the whole backlog, and keep PostHog running for analytics if that’s the part you still want.

Try dif

Install the CLI and scaffold a project. No account or API key required.

npm install -g @dif.sh/cli
dif init

dif init writes a dif/ directory, a typed client, and the flag files. From there, dif new drafts a flag or experiment, dif validate checks it in CI, and dif build compiles it. The feature flags page shows the workflow, and the docs cover install and the SDK in full.

FAQ

Is dif a PostHog alternative? Yes, for the feature-flags-and-experiments slice of PostHog, not the analytics platform around it. dif keeps each flag as a Markdown file reviewed in a pull request, with no separate app. PostHog manages flags inside a broader product that also does analytics, replay, and surveys. Teams that want flags without the rest of that suite are the fit.

Is PostHog or dif better for feature flags? PostHog has more SDK languages and a UI non-engineers can use directly, which matters if your flags need to be toggled outside a pull request. dif fits better when flags should live in the repo, reviewed like code, with a smaller, zero-network-call SDK. Neither is strictly better; they target different workflows.

Are dif and PostHog both open source? Yes. PostHog’s core is MIT licensed, with a handful of enterprise features under a separate license. dif’s CLI and SDK are fully MIT, and there is nothing separate to self-host, because the repo is the only store.

Does PostHog need a network call to evaluate a flag like dif does? Not always. Client-side PostHog SDKs call the /flags endpoint over the network. Server SDKs can run local evaluation against a cached copy of flag definitions, polled periodically with a secret key. dif’s SDK never calls out: the bucket is computed locally from the user ID every time, with no polling and no cache to go stale.

How does pricing compare between dif and PostHog? PostHog’s feature flags are free for the first 1 million requests a month, then billed per request starting at $0.0001, dropping as volume grows. dif Cloud is a flat $50/month for 1 million events, then $0.02 per 1,000, with unlimited seats either way. At a few million events a month the two land close; PostHog’s bundle gets cheaper the more of its other products you also use.