Loading Cargo.toml Generator...
Please wait a moment

How to Generate Cargo.toml - Step by Step Guide

Step 1

Choose your project type

Start by selecting your Cargo project type and filling in the essential manifest information:

•
Binary: Executable application with main.rs
•
Library: Reusable library with lib.rs
•
Workspace: A package that is also the root of a multi-crate workspace; add your member folders to the members list
Step 2

Fill in the package details

Fill in your project's essential details:

*
Package Name: Your crate name (lowercase with hyphens)
*
Version: Semantic version (e.g., 0.1.0, 1.0.0)
*
Edition: Rust edition (2024, 2021, 2018 or 2015)
•
License: MIT, Apache-2.0, or custom
•
Description: Brief project description

Example Configuration

[package]
name = "awesome-cli"
version = "1.0.0"
edition = "2021"
license = "MIT"
Step 3

Add dependencies

Configure your project's crate dependencies:

•
Dependencies: Regular runtime dependencies
•
Dev Dependencies: Testing and development only (criterion, mockall)

Popular Rust Dependencies

serde

Serialization framework

tokio

Async runtime

clap

CLI argument parser

reqwest

HTTP client

Step 4

Download or copy the file

Get the finished Cargo.toml. If the preview shows a note about a name or version, fix that first:

•
Download: Save as Cargo.toml to your project root
•
Copy: Copy to clipboard and paste into your editor
✓
Validate: Use Cargo.toml Validator to check syntax

What is Cargo.toml? 📦

Cargo.toml is the manifest file for Rust projects. It contains metadata about your package and lists all dependencies. Every Rust project needs a Cargo.toml file in the project root directory. Cargo uses this file to manage dependencies, compile your project, and publish to crates.io.

The file uses TOML format (Tom's Obvious, Minimal Language) which is easy to read and write. It defines package metadata, dependencies, dev-dependencies, build-dependencies, features, and more.

Frequently Asked Questions

What are the required fields in Cargo.toml?

Only the package name is strictly required. Since Rust 1.75 the version can be left out (Cargo treats the crate as 0.0.0 and won't publish it), and if edition is missing Cargo falls back to 2015 with a warning. In practice you want all three: name, a version like 0.1.0 and an edition such as 2021 or 2024. Description, license and repository only matter once you publish to crates.io, where they are expected.

How do I specify dependency versions?

A plain version is a caret requirement: "1.0" allows any 1.x release and "1.0.5" allows 1.0.5 or newer up to (but not including) 2.0.0, exactly like "^1.0.5". Use "~1.0.5" to stay below 1.1.0, "=1.0.5" to pin one exact release, and "*" for any version. If the generator can't read a requirement the way Cargo would, it tells you above the preview.

What's the difference between dependencies and dev-dependencies?

[dependencies] are needed to compile and run your crate. [dev-dependencies] are only used for tests, examples and benchmarks, and they are not pulled in when someone else depends on your crate, which keeps their builds smaller. Criterion for benchmarks or mockall for mocks are typical dev-dependencies.

Should I create a binary, a library or a workspace?

Pick Binary for something you run, like a CLI tool or a web server; the file gets a [[bin]] section pointing at src/main.rs. Pick Library for code other crates use; you get a [lib] section with the name written with underscores, as Rust expects. Pick Workspace when this package should also be the root of a multi-crate repository: the file gets a [workspace] section with an empty members list where you add the folders of your other crates, for example "crates/core".

Can I use the generated Cargo.toml straight away?

Usually yes. Every value is escaped, so quotes, backslashes, line breaks or emoji in the description still give a valid TOML file, and the preview warns you when something would make Cargo refuse it: a package name with spaces or a leading digit, a version that is not a full x.y.z version, a dependency without a name or with a requirement Cargo can't parse. Save it as Cargo.toml in the project root, add src/main.rs or src/lib.rs, and run cargo build. The generator doesn't check whether a crate actually exists on crates.io; Cargo does that on the first build.

Is anything I type sent to a server?

No. The Cargo.toml is put together by JavaScript in your browser and the download is created on your machine. Nothing is uploaded and nothing is kept, so reloading the page starts again from the default project.

Related pages: Cargo.toml Validator · Rust Validator · TOML Validator