.RB

RB File

Ruby Source Code File
Ask a question
QUICK ANSWER

An RB file is a Ruby source code file. Open it in any text editor (VS Code, Notepad++) to read the code, or run it from a terminal with "ruby file.rb" after installing Ruby. Never run an RB file from an untrusted source without reading it first.

Developer: Yukihiro "Matz" Matsumoto / Ruby community (Ruby Association) Category: Developer Files Open standard MIME: application/x-ruby
OPENS ON Windows macOS Linux Web
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Jul 9, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the RB file format?

.rb files are associated with the Ruby programming language. Files with the .rb extension contain source code written in Ruby - an interpreted, object-oriented scripting language created by Yukihiro "Matz" Matsumoto. .rb files can be edited in any plain-text editor. In order to run .rb programs, a Ruby environment must be installed; scripts are typically executed with the ruby filename.rb command.

Ruby has developed into a very popular programming language with a rich ecosystem and strong community support. Its main features are simplicity, expressive syntax, and multi-platform support across Windows, macOS and Linux. Ruby is available under an open-source licence (Ruby Licence and BSD 2-Clause) - not a copyleft licence. Ruby is consistently ranked among the widely used programming languages worldwide and is frequently recommended as a first programming language for beginners.

.rb is the canonical source unit for standalone scripts, Ruby on Rails web applications, and libraries distributed as .gem packages. Related formats that share Ruby syntax include .erb embedded template files and .rake build scripts.

Security & safety

RISK: MEDIUM

A .rb file is source code: opening it in a text editor or viewer is completely safe. The risk is in RUNNING it - "ruby file.rb" executes whatever the script contains, including file deletion, network calls, or installing software. Never run a Ruby script from an untrusted source without reading it first. Be wary of scripts that shell out (system/backticks/exec), download code at runtime, or require unknown gems. Reading the plain text before execution is the safe approach.

Format details

in a nutshell
FULL NAMERuby Source Code Fileaka Ruby script, Ruby source file
DEVELOPERYukihiro "Matz" Matsumoto / Ruby community (Ruby Association)since 1995 (Ruby 0.95 public release; Ruby 1.0 in December 1996)
MIME TYPEapplication/x-ruby
TYPEPlain-text programming-language source code
STANDARDOpen · royalty-free

Programs that open RB files

Windows4 apps
Notepad Open-source Open to view/edit the source with Ruby syntax highlighting (does not run it).
Visual Studio Code Free Open the .rb file; install the Ruby/Ruby LSP extension for highlighting and run with the integrated terminal.
Ruby (interpreter, RubyInstaller) Open-source Install Ruby, then run 'ruby file.rb' in Command Prompt or PowerShell to execute the script.
RubyMine Paid Full Ruby/Rails IDE; open the project and run/debug the .rb file.
macOS3 apps
TextMate Open-source Open to view/edit Ruby source (TextMate's Ruby bundle has long-standing support).
Ruby (interpreter) Open-source macOS ships with Ruby; for current versions install via Homebrew or rbenv, then run 'ruby file.rb'.
Visual Studio Code Free Open the file with the Ruby LSP extension; edit and run from the integrated terminal.
Linux2 apps
Ruby (interpreter) Open-source Install via apt/dnf/pacman or rbenv, then run 'ruby file.rb' or 'chmod +x' and execute directly.
Visual Studio Code / VSCodium Open-source Open with the Ruby LSP extension to edit and run.
Web1 app
GitHub / online viewers Free View any .rb file in a repository with syntax highlighting in the browser; no install needed to read it.

Technical details

deep spec
MIME typeapplication/x-ruby; also registered as text/x-ruby and text/x-ruby-script
File encodingUTF-8 plain text (default since Ruby 2.0; earlier versions required `# encoding: utf-8` on line 1 or 2 for non-ASCII source)
Magic bytes / signatureNone - plain text with no fixed byte signature; executable scripts typically begin with a shebang line (`#!/usr/bin/env ruby`)
Interpreter command`ruby filename.rb` at the command line; Windows users typically invoke `ruby.exe` via RubyInstaller
Frozen-string pragma`# frozen_string_literal: true` on line 1 makes all string literals immutable at runtime, improving performance (available since Ruby 2.3)
Syntax versioningNo file-level version field; syntax compatibility is governed by the interpreter version (1.8, 1.9, 2.x, 3.x)
Encoding declarationOptional magic comment `# encoding: <name>` (or `# coding: <name>`) on line 1 or 2; mandatory for non-ASCII source on Ruby < 2.0
Typical file size1 KB - 100 KB; most application files fall in the 2-30 KB range
Internal structureSequential Ruby statements - require/load calls, class and module definitions, method (def) bodies, expressions; executed top-to-bottom by the interpreter
Related extensions`.rbw` (Windows silent-mode, no console), `.gemspec`, `.rake`, `.ru` (Rack config), `.erb` (embedded Ruby template)
Platform supportCross-platform: Windows, macOS, Linux, BSD, and any OS with a Ruby interpreter (MRI/CRuby, JRuby, TruffleRuby)
Primary use casesStandalone automation scripts, Ruby on Rails controllers and models, RubyGems library source, Rakefiles (build tasks), Vagrantfiles, and Homebrew formulae
Released1995 (Ruby 0.95 public release; Ruby 1.0 in December 1996)
Latest versionTracks the Ruby language; Ruby 3.4 (December 2024). Source files are version-agnostic text.
Open standardYes · royalty-free
Specificationwww.ruby-lang.org

RB conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with RB files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about RB files.

Frequently asked questions

How do I open a .rb file?
To read or edit it, open it in any text editor or code editor (VS Code, Notepad++, Sublime Text). To run it, install Ruby and execute 'ruby file.rb' in a terminal.
How do I run a Ruby (.rb) file?
Install Ruby (RubyInstaller on Windows, Homebrew/rbenv on macOS, your package manager on Linux), open a terminal in the file's folder, and run 'ruby yourscript.rb'.
Can I convert a .rb file to an .exe?
Not by direct conversion, but you can bundle the script with the Ruby interpreter into a standalone Windows .exe using OCRA, ruby-packer (rubyc), or Tebako. The result ships the runtime inside it.
Is a .rb file the same as a text file?
Yes - it's plain UTF-8 text. The .rb extension just tells tools it contains Ruby code. You can open it with any text editor or rename it to .txt to view it.
Why does my .rb script fail to run?
Common causes: Ruby isn't installed or isn't on your PATH, the script targets a different Ruby version, or it requires gems you haven't installed (run 'bundle install' if there's a Gemfile).
What's the difference between .rb and .rbw?
.rbw is the Windows variant that runs a Ruby script with rubyw.exe - without opening a console window - typically for GUI apps. The code inside is identical Ruby.

References

1Ruby - official site and documentationwww.ruby-lang.org
2RubyInstaller for Windowsrubyinstaller.org

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.MDMarkdown Document
4.BINCD/DVD Disc Image (BIN/CUE)
5.NOMEDIAAndroid No-Media Marker File
6.PARTPartial Download File
7.RPMSGRestricted Permission Message
8.EXEWindows Executable (Portable Executable)
9.AVIFAV1 Image File Format (AVIF)
10.DBSQLite Database File

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z