---
title: "Invert Object Keys and Values"
description: "Swap the keys and values of an object in TypeScript."
date: "2025-10-02"
tags: ["typescript","object","invert","frontend"]
canonical: "/snippets/typescript/object/invert"
---

import { Code } from '@astrojs/starlight/components'
import Source from './invert.ts?raw'

## Invert Object Keys and Values

<Code code={Source} lang="ts" title="invert.ts" wrap />
