✦ Dart & Flutter 📦 Pub package ⚡ Zero dependencies

youtube_search_id

Extract YouTube video IDs from search results effortlessly. Lightweight, fast, and built for Dart & Flutter projects.


✨ Why use this package?

Built for developers who need reliable video ID extraction without scraping complexity.

🔍

Smart parsing

Extracts IDs from search results, URLs, and short links with high accuracy.

Lightweight

Zero external dependencies — keeps your project lean and fast.

🛡️

Error resilient

Gracefully handles malformed inputs and returns empty results when needed.

📱

Flutter ready

Works seamlessly in mobile, desktop, and web Flutter applications.

🧪

Fully tested

Comprehensive test suite ensures reliability across edge cases.

📦

Type safe

Strong Dart typing with clear return types for better DX.


📥 Installation

Add the package to your pubspec.yaml or use the CLI.

# pubspec.yaml
dependencies:
  youtube_search_id: "^1.2.0"

🚀 Usage

Simple, intuitive API to get video IDs from any YouTube search input.

🔎 Basic search

import 'package:youtube_search_id/youtube_search_id.dart';

void main() {
  final ids = getVideoIds('flutter tutorial 2026');
  print(ids); // ['abc123', 'def456', ...]
}
📹 abc123 Flutter 2026 Beginner Guide
📹 def456 Advanced Flutter Patterns
📹 ghi789 Flutter State Management

🔗 From URL or shortlink

import 'package:youtube_search_id/youtube_search_id.dart';

void main() {
  final urlId = extractIdFromUrl(
    'https://youtu.be/abc123xyz'
  );
  print(urlId); // 'abc123xyz'

  final searchId = getVideoIds('https://youtube.com/watch?v=abc123xyz');
  print(searchId); // ['abc123xyz']
}
🎯 abc123xyz from URL

📘 API Reference

All the functions you need to get YouTube video IDs.

getVideoIds(String input)

Accepts a search query or a YouTube URL and returns a list of video IDs found.

List<String>
extractIdFromUrl(String url)

Extracts a single video ID from a full YouTube URL or shortlink.

String? (nullable)
extractIdsFromText(String text)

Scans any text for YouTube video IDs (regex-based). Returns all matches.

List<String>
isValidId(String id)

Checks if a string is a valid YouTube video ID (11 characters, alphanumeric + - _).

bool