--- title: Typed parameters description: Declare statically typed pipeline parameters in Nextflow using the params block. --- # Typed parameters Typed parameters let you declare a pipeline's parameters, their types, and their default values in a single `params` block. Nextflow uses the annotations to validate every parameter reference against its declared type. ```nextflow params { // Path to input data. input: Path // Whether to save intermediate files. save_intermeds: Boolean // Maximum number of iterations. max_iterations: Integer = 100 } workflow { analyze(params.input, params.save_intermeds, params.max_iterations) } ``` The `params` block does not require the `nextflow.enable.types` feature flag. For an overview of static typing and how to enable it, see [Static typing][static-typing-page]. For the complete syntax reference, see [Params block][syntax-params-block]. ## Supported types Parameters can use any [standard type][stdlib-types]. This includes primitive types such as `Path`, `String`, `Integer`, and `Boolean`, as well as collections, records, and the dataflow types (`Channel` and `Value`). A parameter can be declared with a dataflow type: - A `Channel` parameter accepts a samplesheet path, which Nextflow loads as a channel of records. The samplesheet file can be CSV, JSON, or YAML. The element type must be `Map`, `Record`, or a record type. Each row is validated against and converted to the declared type. - A `Value` parameter accepts a value of type `V`, which Nextflow wraps in a value channel. For example: ```nextflow params { samples: Channel index: Value } workflow { RNASEQ(params.samples, params.index) } record Sample { id: String fastq_1: Path fastq_2: Path } ``` The pipeline can be run with a samplesheet and an index file: ```console $ nextflow run main.nf --samples samples.csv --index genome.fa ``` Dataflow types are useful when a pipeline is [included by another pipeline][pipeline-composition], because they allow the calling pipeline to provide a parameter from dataflow logic. ## Default and required parameters A parameter can optionally specify a default value: - A parameter that specifies a default value is *optional*. If no value is supplied at runtime, the default is used. - A parameter that does not specify a default value is *required*. If a required parameter has no value at runtime, the run fails. Boolean parameters that don't specify a default value default to `false` rather than being treated as required. Input files declared as `Path` must already exist when the pipeline is launched. Use `String` for file paths that are created by the pipeline. ## Overriding parameters A parameter's default value can be overridden on the command line, in a params file, or in a config file. When a parameter is set from more than one source, Nextflow resolves the final value in the order described in [Pipeline parameters][cli-params]. Nextflow converts command-line parameters to the type set by their annotation. For example, a parameter declared as `Integer` receives an integer value, not the string entered on the command line. ## Referencing parameters Typed parameters should only be referenced in the entry workflow or the `output` block. To use a parameter elsewhere, pass it to a workflow or process as an explicit input. ## Validation The language server validates each parameter reference against its declared type. Referencing a parameter in a context that expects a different type is reported as an error before the pipeline runs. ## See also - [Static typing][static-typing-page]: Overview of static typing and how to enable it. - [Standard types][stdlib-types]: The standard types available for annotations. - [Pipeline parameters][cli-params]: How parameter values are resolved across sources. [cli-params]: ./cli#pipeline-parameters [pipeline-composition]: ./workflow-typed#pipeline-composition [static-typing-page]: ./static-typing [stdlib-types]: ./reference/stdlib-types [syntax-params-block]: ./reference/syntax#params-block