<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/protobuf-tip-10-choosing-the-right-integer-type-buf-hvt0qpyq7" -->

---
title: Protobuf Tip #10: Choosing the right integer type · Buf
description: Protobuf offers ten integer types across three encoding families (varint, ZigZag varint, and fixed-size), but for practical purposes int64 remains the right...
canonical: https://daily.dev/posts/protobuf-tip-10-choosing-the-right-integer-type-buf-hvt0qpyq7
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Protobuf Tip #10: Choosing the right integer type · Buf | daily.dev
og:description: Protobuf offers ten integer types across three encoding families (varint, ZigZag varint, and fixed-size), but for practical purposes int64 remains the right...
og:url: https://daily.dev/posts/protobuf-tip-10-choosing-the-right-integer-type-buf-hvt0qpyq7
og:image: https://api.daily.dev/og/posts/hvt0qpyQ7.png
og:image:alt: Protobuf Tip #10: Choosing the right integer type · Buf
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Protobuf Tip #10: Choosing the right integer type · Buf

**[Buf Blog](https://daily.dev/sources/buf)** · 6 min read · 0 upvotes · 0 comments

## Summary

Protobuf offers ten integer types across three encoding families (varint, ZigZag varint, and fixed-size), but for practical purposes int64 remains the right default choice. Benchmarks using the standard google.golang.org/protobuf runtime on 1,000 packed integers show the slowest case (negative int64) takes under 6 microseconds, with fixed64 types up to five times faster than negative int64 in raw terms, yet all differences are negligible compared to JSON encoding, which is far slower. The one exception is truly random 64-bit values like hashes or IDs, where fixed64 can be smaller and cheaper to decode than a varint type since nearly every value is large. Benchmark details, including a comparison against encoding/json and encoding/json/v2 under Go 1.26's jsonv2 experiment, are included in an appendix.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://buf.build/blog/choosing-the-right-protobuf-integer-type>

## Questions this post answers

### Which protobuf integer type should I use by default for a new field?

Use int64 as the default. It handles negative values correctly, keeps small values compact on the wire through varint encoding, and the performance difference versus other integer types is negligible: even the slowest case, decoding 1,000 negative int64 values, takes under 6 microseconds, far faster than JSON encoding of the same data.

_daily.dev surfaces practical protobuf schema guidance for developers weighing encoding tradeoffs._

### When should I use fixed64 instead of int64 in a protobuf schema?

Use fixed64 when the field holds essentially random 64-bit values, such as hashes or generated IDs. Varint encoding only saves space when values are small, but random 64-bit numbers are almost always large, so fixed64's constant 8-byte little-endian encoding ends up both smaller and cheaper to decode than int64 or uint64 varints in that specific case.

_Developers picking data types for high-throughput services can track these tradeoffs on daily.dev._

### How much faster is fixed64 than int64 for decoding negative integers in protobuf with Go?

Fixed64 decoding of negative values takes about 1,208 nanoseconds for 1,000 values, versus 5,793 nanoseconds for int64, roughly five times faster, based on benchmarks run with google.golang.org/protobuf v1.36.11 on Go 1.26.5 on an Apple M5 Pro. Despite the ratio, both numbers are under 6 microseconds total, making the difference negligible in most real services.

_daily.dev helps engineers comparing Go serialization benchmarks stay grounded in real numbers, not just ratios._

## Similar posts on daily.dev

- [Delta Encoding in Protobuf · Buf](https://daily.dev/posts/delta-encoding-in-protobuf-buf-zeigpe4jh) · Buf Blog · 0 upvotes · 0 comments
- [Better than JSON](https://daily.dev/posts/better-than-json-d2je9kyed) · Hacker News · 250 upvotes · 22 comments
- [A Million Go Map Entries Take 38MB, Not 16MB](https://daily.dev/posts/a-million-go-map-entries-take-38mb-not-16mb-lnqjibqce) · Awesome Go · 30 upvotes · 1 comments

---

Tags: [#backend](https://daily.dev/tags/backend), [#golang](https://daily.dev/tags/golang)

[View this post on daily.dev](https://daily.dev/posts/protobuf-tip-10-choosing-the-right-integer-type-buf-hvt0qpyq7)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Protobuf Tip #10: Choosing the right integer type · Buf","url":"https://daily.dev/posts/protobuf-tip-10-choosing-the-right-integer-type-buf-hvt0qpyq7","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/protobuf-tip-10-choosing-the-right-integer-type-buf-hvt0qpyq7"},"datePublished":"2026-08-23T07:20:08.825Z","dateModified":"2026-08-23T07:20:31.807Z","description":"Protobuf offers ten integer types across three encoding families (varint, ZigZag varint, and fixed-size), but for practical purposes int64 remains the right...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0b57262241f44cd482906fd140bd167e?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0b57262241f44cd482906fd140bd167e?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Buf Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Buf Blog","logo":"https://media.daily.dev/image/upload/s--2YBgo_Nm--/f_auto,q_auto/v1787469605/logos/buf?_a=BAMAMicg0","url":"https://daily.dev/sources/buf"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/protobuf-tip-10-choosing-the-right-integer-type-buf-hvt0qpyq7","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"backend,golang","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Buf Blog","item":"https://daily.dev/sources/buf"},{"@type":"ListItem","position":3,"name":"Protobuf Tip #10: Choosing the right integer type · Buf"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/protobuf-tip-10-choosing-the-right-integer-type-buf-hvt0qpyq7#faq","mainEntity":[{"@type":"Question","name":"Which protobuf integer type should I use by default for a new field?","acceptedAnswer":{"@type":"Answer","text":"Use int64 as the default. It handles negative values correctly, keeps small values compact on the wire through varint encoding, and the performance difference versus other integer types is negligible: even the slowest case, decoding 1,000 negative int64 values, takes under 6 microseconds, far faster than JSON encoding of the same data. daily.dev surfaces practical protobuf schema guidance for developers weighing encoding tradeoffs."}},{"@type":"Question","name":"When should I use fixed64 instead of int64 in a protobuf schema?","acceptedAnswer":{"@type":"Answer","text":"Use fixed64 when the field holds essentially random 64-bit values, such as hashes or generated IDs. Varint encoding only saves space when values are small, but random 64-bit numbers are almost always large, so fixed64's constant 8-byte little-endian encoding ends up both smaller and cheaper to decode than int64 or uint64 varints in that specific case. Developers picking data types for high-throughput services can track these tradeoffs on daily.dev."}},{"@type":"Question","name":"How much faster is fixed64 than int64 for decoding negative integers in protobuf with Go?","acceptedAnswer":{"@type":"Answer","text":"Fixed64 decoding of negative values takes about 1,208 nanoseconds for 1,000 values, versus 5,793 nanoseconds for int64, roughly five times faster, based on benchmarks run with google.golang.org/protobuf v1.36.11 on Go 1.26.5 on an Apple M5 Pro. Despite the ratio, both numbers are under 6 microseconds total, making the difference negligible in most real services. daily.dev helps engineers comparing Go serialization benchmarks stay grounded in real numbers, not just ratios."}}]}
```

