The NIMBLE hierarchical modeling package provides a flexible system for working with ecological models. NIMBLE is compatible with WinBUGS and JAGS for writing models but provides extensibility and flexibility. Models can include new distributions and functions provided by the user. MCMC sampler choices can be customized, and new samplers easily written. NIMBLE's algorithm programming language supports methods beyond MCMC, such as model selection and validation and provides a platform for methodologists/developers to disseminate their own methods. These features enable the use of increasingly sophisticated statistical models in ecology. We illustrate NIMBLE's use with various important ecological models. For multi-state capture-recapture models and multi-species dynamic occupancy models, NIMBLE allows direct marginalization over individual latent states, greatly reducing dimensionality and improving MCMC efficiency. For spatial capture-recapture models, new formulations of common models and customized MCMC samplers (including reversible jump) improve performance. We illustrate model selection via cross-validation and model assessment via calibrated posterior predictive p-values.